package com.hsnn.medstgmini.pro.project.controller;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Type;
import java.net.URLDecoder;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.hsnn.medstgmini.Constants;
import com.hsnn.medstgmini.base.dict.model.DicSys;
import com.hsnn.medstgmini.base.dict.model.form.DicAreaForm;
import com.hsnn.medstgmini.base.dict.service.DicAreaManager;
import com.hsnn.medstgmini.base.dict.service.DicSysManager;
import com.hsnn.medstgmini.base.std.model.HospInfo;
import com.hsnn.medstgmini.base.std.model.StdCompinfo;
import com.hsnn.medstgmini.base.std.service.StdCompinfoManager;
import com.hsnn.medstgmini.base.std.service.StdHospInfoManager;
import com.hsnn.medstgmini.model.Whether;
import com.hsnn.medstgmini.pro.base.model.form.FileUploadResult;
import com.hsnn.medstgmini.pro.project.model.BidProjCompany;
import com.hsnn.medstgmini.pro.project.model.BidProjdrugs;
import com.hsnn.medstgmini.pro.project.model.BidProject;
import com.hsnn.medstgmini.pro.project.model.BidProjhospital;
import com.hsnn.medstgmini.pro.project.model.BidPubSettings;
import com.hsnn.medstgmini.pro.project.model.form.BidProjectDetailLogForm;
import com.hsnn.medstgmini.pro.project.model.form.BidProjectForm;
import com.hsnn.medstgmini.pro.project.model.form.BidPurProjDrugsForm;
import com.hsnn.medstgmini.pro.project.service.BidProjcompprofileManager;
import com.hsnn.medstgmini.pro.project.service.BidProjectManager;
import com.hsnn.medstgmini.pro.project.validator.BidProjectValidator;
import com.hsnn.medstgmini.sys.model.SysImportFileInfo;
import com.hsnn.medstgmini.sys.model.SysUser;
import com.hsnn.medstgmini.sys.service.SysImportFileInfoManager;
import com.hsnn.medstgmini.util.AccountUtil;
import com.hsnn.medstgmini.util.AreaUtil;
import com.hsnn.medstgmini.util.ConstantsUtil;
import com.hsnn.medstgmini.util.DateUtil;
import com.hsnn.medstgmini.util.DbUtil;
import com.hsnn.medstgmini.util.DicSysUtil;
import com.hsnn.medstgmini.util.FileUtil;
import com.hsnn.medstgmini.util.Pagination;
import com.hsnn.medstgmini.util.ParseDate;
import com.hsnn.medstgmini.util.ParseNumber;
import com.hsnn.medstgmini.util.form.FileLoadForm;
import com.hsnn.medstgmini.validator.Result;

/**
 * 
 * @category 采购项目管理
 * @author 邱磊
 * @param <StdDrugInfo>
 * @date 2015年6月11日 上午9:07:01
 */
@Controller
@RequestMapping("/bidProject")
public class BidProjectController<StdDrugInfo> {

	private static final Logger logger = LoggerFactory.getLogger(BidProjectController.class);

	@Autowired
	private BidProjectManager bidProjectManager;

	@Autowired
	private DicSysManager dicSysManager;
	@Autowired
	private SysImportFileInfoManager sfmanager;
	@Autowired
	private HttpServletRequest request;
	@Autowired
	private HttpServletResponse response;
	
	@Autowired
	private BidProjcompprofileManager bidProjcompprofileManager;
	@Autowired
	private StdHospInfoManager hospInfoManager;
	@Autowired
	private StdCompinfoManager stdCompinfoManager;
	@Value("#{sysProp['system.importDrugMobanPath']}")
	private String importDrugMobanPath;
	@Value("#{sysProp['system.importDrugMoban']}")
	private String importDrugMoban;
	@Value("#{sysProp['system.uploadPath']}")
	private String uploadPath;
	@Value("#{sysProp['system.importDrugResultPath']}")
	private String importDrugResultPath;

 	BidProjectValidator bidProjectValidator = new BidProjectValidator();
	/**
	 * 
	 * @category 跳向采购项目列表
	 * @author 邱磊
	 * @date 2015年6月11日 上午10:54:04
	 * @return
	 */
	@RequestMapping("/toList")
	public String toList() {
		return "/pro/project/bidProjectList";
	}

	/**
	 * 
	 * @category 跳向交易模块的项目列表页面
	 * @author 邱磊
	 * @date 2015年6月24日 下午2:01:34
	 * @return
	 */
	@RequestMapping("/toDelList")
	public String toDelList() {
		return "/pro/project/bidProjectDealList";
		
	}

	/**
	 * 
	 * @category 查询采购项目列表
	 * @author 邱磊
	 * @date 2015年6月11日 上午11:48:38
	 * @param projCode
	 * @param name
	 * @param status
	 * @return
	 */
	@RequestMapping("/getDataList")
	@ResponseBody
	public Pagination getDataList() {
		Pagination page = new Pagination(request);
		SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
		if (StringUtils.isNotBlank(user.getDefaultProjId())) {//已设置默认项目
			page.getConditions().put("projId", user.getDefaultProjId());
			page.setForm(user.getDefaultProjId());
		}else{
			if (StringUtils.isNotBlank(request.getParameter("projId"))) {
				page.getConditions().put("projId", request.getParameter("projId"));
			}
			if (StringUtils.isNotBlank(request.getParameter("status"))) {
				page.getConditions().put("status", request.getParameter("status"));
			}
			page.getConditions().put("orderBy", request.getParameter("orderBy"));//判断采购项目列表排序规则
		}
		return bidProjectManager.getDataList(page);
	}

	/**
	 * 
	 * @category 查询采购项目列表
	 * @author 单大伟
	 * @date 2015年6月11日 上午11:48:38
	 * @param projCode
	 * @param name
	 * @param status
	 * @return
	 */
	@RequestMapping("/getProjWithPlanList")
	@ResponseBody
	public Pagination getProjWithPlanList(String projCode, String name, String status) {
		Pagination page = new Pagination(request);
		if (null != projCode && !"".equals(projCode.trim())) {
			page.getConditions().put("projCode", projCode.trim());
		}
		if (null != name && !"".equals(name.trim())) {

			page.getConditions().put("name", name.trim());
		}
		if (null != status && !"".equals(status.trim())) {
			page.getConditions().put("status", status.trim());
		}
		return bidProjectManager.getProjWithPlanList(page);
	}
	
	/**
	 * 
	 * @category 启用、停用
	 * @author 邱磊
	 * @date 2015年6月24日 上午9:48:36
	 * @param projId
	 *            项目ID
	 * @param status
	 *            状态：1启用，0停用
	 * @return
	 */
	@RequestMapping("/switchStatus")
	@ResponseBody
	public String switchStatus(BidProject data,String array) {
		Pagination page = new Pagination(request);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		data.setUpdUser(user.getId());
		try {
			
			if (StringUtils.isNotBlank(array)) {
				Gson gson = new Gson();
				Type type = new TypeToken<List<BidProject>>() {
				}.getType();
				List<BidProject> list = gson.fromJson(array, type);
				if (list != null && list.size()>0) {
					for (BidProject bp : list) {
						bp.setUpdUser(user.getId());
						bidProjectManager.switchStatus(bp);
					}
					page.setSuccess(true);
				}
			}
			//bidProjectManager.switchStatus(data);
			return "success";
		} catch (Exception e) {
			logger.error("启停操作失败：", e);
			return "failed";
		}
	}

	@Autowired
	private DicAreaManager dicAreaManager;
	@Value("#{sysProp['system.province']}")
	private String province;
	@Value("#{sysProp['system.provname']}")
	private String provname;
	

	

	/**
	 * 
	 * @category 添加医疗机构
	 * @author 邱磊
	 * @date 2015年6月24日 上午9:46:55
	 * @param porjId
	 * @param hospId
	 * @return
	 */
	@RequestMapping("/addHost")
	@ResponseBody
	public String addHost(String porjId, String hospId) {
		SysUser sysUser = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		return bidProjectManager.addHost(porjId, hospId, sysUser.getId());
	}

	
	

	
	
	

	/**
	 * @category 项目已添加药品批量启用停用
	 * @author 韩守松
	 * @date 2015年7月8日
	 * @param @return
	 */
	@RequestMapping("/batchChangeHospStatus")
	@ResponseBody
	public boolean batchChangeHospStatus(BidProjhospital bidProjhospital) {
		boolean flag = false;
		try {
			Date date = new Date();
			String projHospIdList = request.getParameter("array");
			String projHospId = "";
			Short status = null;
			String projId = "";
			String hospCode = "";
			SysUser sysUser = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			JSONArray jsonarray = JSON.parseArray(projHospIdList);
			for (int i = 0; i < jsonarray.size(); i++) {
				JSONObject json = (JSONObject) jsonarray.get(i);
				projHospId = json.getString("projHospId");
				status = json.getShortValue("status");
				projId = json.getString("projId");
				hospCode = json.getString("hospCode");
				bidProjhospital.setProjHospId(projHospId);
				bidProjhospital.setProjId(projId);
				bidProjhospital.setHospCode(hospCode);
				bidProjhospital.setStatus(status);
				bidProjhospital.setUpdDatetime(date);
				bidProjhospital.setUpdUser(sysUser.getId());
				flag = bidProjectManager.batchUpdateHospStatus(bidProjhospital, bidProjhospital.getStatus());
			}
			return flag;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("已添加药品批量处理出错-->" + e);
			return flag;
		}

	}
	/**
	 * @category 项目已添加药品启用停用
	 * @author 韩守松
	 * @date 2015年7月8日
	 * @param @return
	 */
	@RequestMapping("/changeHospStatus")
	@ResponseBody
	public boolean changeHospStatus(BidProjhospital bidProjhospital) {
		boolean flag = false;
		String projHospId = request.getParameter("projHospId");
		String status = request.getParameter("status");
		SysUser sysUser = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		try {
			bidProjhospital.setProjHospId(projHospId);
			if (StringUtils.isNotEmpty(status)) {
				bidProjhospital.setStatus(Short.valueOf(status));
			}
			bidProjhospital.setUpdDatetime(new Date());
			bidProjhospital.setUpdUser(sysUser.getId());

			flag = bidProjectManager.updateHospStatus(bidProjhospital, bidProjhospital.getStatus());
			return flag;
		} catch (Exception e) {
			e.printStackTrace();
			logger.error("采购项目药品信息保存修改错误-->" + e);
			return flag;
		}
	}
	/**
	 * @category 跳转未添加药品页面
	 * @auth 陈镜宇
	 * @param model
	 * @param bidProject
	 * @return
	 * @date 2015年6月11日
	 */
	@RequestMapping("/toUnBidProjectDrugsList")
	public String toUnBidProjectDrugsList(Model model, BidProject bidProject) {
		model.addAttribute("bidProject", bidProjectManager.getBidProjectById(bidProject.getProjId()));
		return "/pro/project/bidProjectDrugsEdit";
	}

	/**
	 * 
	 * @category 获取非项目药品数据
	 * @auth 陈镜宇
	 * @param projId
	 * @return
	 * @date 2015年6月11日
	 */
	@ResponseBody
	@RequestMapping("/getUnBidProjectDrugListJson")
	public Pagination getUnBidProjectDrugListJson(String projId,
			String sdrugCode, String sdrugName, String sdrugComp,
			String sbaseDrug, String slowDrug) {
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", projId);
		page.getConditions().put("drugCode", sdrugCode);
		page.getConditions().put("drugName", sdrugName);
		page.getConditions().put("drugComp", sdrugComp);
		page.getConditions().put("baseDrug", sbaseDrug);
		page.getConditions().put("lowDrug", slowDrug);
		return bidProjectManager.getUnBidProjectDrugList(page);

	}

	/**
	 * 
	 * @category 批量添加药品目录到项目
	 * @auth 陈镜宇
	 * @param projId
	 * @param drugs
	 * @return
	 * @date 2015年6月12日
	 */
	@ResponseBody
	@RequestMapping("/batchSubmitDrugTOProj")
	public Pagination batchSubmitDrugTOProj(String drugs) {
		Pagination page = new Pagination(request);
		try {
			if (StringUtils.isNotBlank(drugs)) {
				Gson gson = new Gson();
				Type type = new TypeToken<List<BidPurProjDrugsForm>>() {}.getType();
				List<BidPurProjDrugsForm> list = gson.fromJson(drugs, type);
				SysUser loginUser = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				bidProjectManager.batchSubmitDrugTOProj(list, loginUser.getId());
				page.setSuccess(true);
			}
		} catch (Exception e) {
			logger.error("批量添加药品失败：", e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * 
	 * @category 跳向新增或编辑采购项目
	 * @author 邱磊
	 * @date 2015年6月11日
	 * @return
	 */
	@RequestMapping("/toSaveOrUpdate")
	public String toSaveOrUpdate() {
		String projId = request.getParameter("projId");
		if (StringUtils.isNotEmpty(projId)) {
			Map<String, Object> map = bidProjectManager.getDataDetail(projId);
			request.setAttribute("name", "编辑");
			request.setAttribute("bidProject", map);
		}else{
			request.setAttribute("name", "新增");
			String projCode = provname+province+(ParseDate.parseWithNum(new Date()));
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("projCode", projCode);
			request.setAttribute("bidProject", map);
			
		}
		List<DicSys> list = DicSysUtil.getDicListByClassCode(Constants.PROJ_CAT);
		for(DicSys ds :list){
			if ( ds.getDicCode().equals("1")) {//只获取招标采购
				request.setAttribute("ds", ds);
			}
		}
		return "/pro/project/bidProjectEdit";
	}

	/**
	 * 
	 *@category 保存或编辑保存项目信息
	 *@author 邱磊
	 *@date 2015年8月18日 上午8:59:05
	 *@param bidProject
	 *@return
	 */
	@RequestMapping("/saveOrUpdate")
	@ResponseBody
	// jsp 中用js ajaxSubmit 进行触发保存，返回类型是json，所以需要加@ResponseBody
	// spring注解@ResponseBody处理ajax请求，json数据类型
	public Pagination saveOrUpdate(BidProjectForm form) {
		Pagination page = new Pagination();
		Result result = new Result();
		try {
			SysUser sysUser = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
			if (null != form) {
//				result = bidProjectValidator.validate(bidProject);
//				if(result.isSuccess()){
				form.setCreateUser(sysUser.getId());
				form.setUpdUser(sysUser.getId());
				try {
					bidProjectManager.saveOrUpdate(form);
					page.setSuccess(true);
				} catch (Exception e) {
					e.printStackTrace();
					
				}
				
//				}else{
//					page.setResult(result);
//				}
			}

		} catch (Exception e) {
			e.printStackTrace();
			page.setResult(result);
			page.setMsg("保存失败！");
		}
		return page;
	}
	
	/**
	 * 
	 *@category 启用停用（批量）
	 *@author 邱磊
	 *@date 2015年8月18日 下午1:30:21
	 *@param array
	 *@return
	 */
	@RequestMapping("/batchSwitchStatus")
	public Pagination batchSwitchStatus(String array){
		Pagination page = new Pagination();
		if (array != null && !"".equals(array)) {
			Gson gson = new Gson();
			Type type = new TypeToken<List<BidProject>>() {}.getType();
			List<BidProject> list = gson.fromJson(array, type);
			SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
			if (list != null && !list.isEmpty()) {
				try {
					bidProjectManager.batchSwitchStatus(list, user.getId());
					page.setSuccess(true);
				} catch (Exception e) {
					e.printStackTrace();
					page.setMsg("操作失败！");
					page.setSuccess(false);
					return page;
				}
				return page;
			}
		}
		page.setMsg("请选择操作数据！");
		page.setSuccess(false);
		return page;
	}
	/**
	 * 
	 *@category 跳向项目详情页面
	 *@author 邱磊
	 *@date 2015年8月18日 下午2:29:52
	 *@return
	 */
	@RequestMapping("/toDataDetail")
	public String toDataDetail(Model model){
		String projId = request.getParameter("projId");
		Map<String, Object> map = bidProjectManager.getDataDetail(projId);
		request.setAttribute("form", map);
		model.addAttribute("date", ParseDate.parseFullFormat(new Date()));
		return "/pro/project/bidprojectDetail";
	}
	/**
	 * @category 设置密码列表
	 * @Auther 徐国鹏
	 * @date 2015年8月26日 上午9:55:44
	 * @return
	 * @return String
	 */
	@RequestMapping("/toPassWord")
	public String toSetPassWordList(RedirectAttributes attr){
		SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
		String defalutProjId=  user.getDefaultProjId();
		if ( StringUtils.isNotBlank(defalutProjId) ) {
			BidProject bp=  bidProjectManager.getBidProjectById(defalutProjId);
			 attr.addAttribute("projId",defalutProjId);  
		     attr.addAttribute("name", bp.getName());
		     return "redirect:/bidProject/toSetPassword.html";
		}
		
		return "/pro/project/setPassWordList";
	}
	
	
	/**
	 * @category 重定向设置默认密码
	 * @Auther 应晓川
	 * @date 2015年9月15日16:51:04
	 * @return
	 * @return String
	 */
	@RequestMapping("/toSetDefaultPassword")
	public String toSetDefaultPassword(){
		request.setAttribute("projId", request.getParameter("projId"));
		String name = request.getParameter("name");
		try {
			if (StringUtils.isNotBlank(name)){
				name = new String(name.getBytes("ISO8859-1"),"utf-8");
			}
			request.setAttribute("name", name);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.toString());
		}
		return "/pro/project/changeBidProject/setDefaultPassword";
	}
	
	
	
	/**
	 * 
	 *@category 密码修改（输入密码弹窗）
	 *@author 徐国鹏
	 *@date 2015年9月7日 下午1:31:14
	 *@return
	 */
	@RequestMapping("/toWritePassword")
	public String toWritePassword() {
		String projId = request.getParameter("projId");
		BidProjectForm data = bidProjectManager.getPasswordInfo(projId);
		request.setAttribute("data", data);
		return "/pro/project/writePassword";
	}
	/**
	 * @category 招标阶段设置列表
	 * @Auther 徐国鹏
	 * @date 2015年8月26日 上午9:55:44
	 * @return
	 * @return String
	 */
	@RequestMapping("/toCheckPasswordList")
	public String toCheckPasswordList(RedirectAttributes attr){
			SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
			String defalutProjId=  user.getDefaultProjId();
			if ( StringUtils.isNotBlank(defalutProjId) ) {
				BidProject bp=  bidProjectManager.getBidProjectById(defalutProjId);
				 attr.addAttribute("projId",defalutProjId);  
			     attr.addAttribute("name", bp.getName());
			     return "redirect:/bidProject/checkDefaultPasswordList.html";
			}
		return "/pro/project/checkPasswordList";
	}
	
	/**
	 * 
	 *@category 跳向默认项目的设置招标密码页面
	 *@author 应晓川
	 *@date 2015年9月16日09:37:53
	 *@return 
	 */
	@RequestMapping("/checkDefaultPasswordList")
	public String checkDefaultPasswordList(){
		request.setAttribute("projId", request.getParameter("projId"));
		String name = request.getParameter("name");
		try {
			if (StringUtils.isNotBlank(name)){
				name = new String(name.getBytes("ISO8859-1"),"utf-8");
			}
			request.setAttribute("name", name);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.toString());
		}
		return "/pro/project/changeBidProject/checkDefaultPasswordList";
	}
	
	/**
	 * 
	 *@category 跳向设置招标密码页面
	 *@author 邱磊
	 *@date 2015年8月21日 上午8:14:13
	 *@return
	 * @throws UnsupportedEncodingException 
	 */
	@RequestMapping("/toSetPassword")
	public String toSetPassword() throws UnsupportedEncodingException{
		//默认项目，判断是否显示返回按钮
		SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
		String defalutProjId=  user.getDefaultProjId();
		if(StringUtils.isNotBlank(defalutProjId)){
			request.setAttribute("defalutProjId", defalutProjId);
		}
		String name = new String(request.getParameter("name").getBytes("ISO8859-1"),"UTF-8");
		request.setAttribute("name", name);
		String projId = request.getParameter("projId");
		BidProjectForm data = bidProjectManager.getPasswordInfo(projId);
		request.setAttribute("data", data);
		return "/pro/project/setProjPassword";
	}
	/**
	 * 
	 *@category 设置招标密码
	 *@author 邱磊
	 *@date 2015年8月21日 上午8:38:26
	 *@return
	 */
	@RequestMapping("/setPassword")
	@ResponseBody
	public Pagination setPassword(){
		Pagination page = new Pagination();
		String passwordCount = request.getParameter("passwordCount");
		if (StringUtils.isNotBlank(passwordCount)){
			String[] pswd = new String[ParseNumber.toInteger(passwordCount)];
			String[] pswdConfirm = new String[ParseNumber.toInteger(passwordCount)];
			String[] newPswd = new String[ParseNumber.toInteger(passwordCount)];
			String[] newPswdConfirm = new String[ParseNumber.toInteger(passwordCount)];
			for (int i = 1; i <= ParseNumber.toInteger(passwordCount); i++){
				pswd[i-1] = request.getParameter("password"+i);
				pswdConfirm[i-1] = request.getParameter("passwordConfirm"+i);
				newPswd[i-1] = request.getParameter("newPassword"+i);
				newPswdConfirm[i-1] = request.getParameter("newPasswordConfirm"+i);
			}
			page.getConditions().put("projId", request.getParameter("projId"));
			page.getConditions().put("firstSetPswd", request.getParameter("firstSetPswd"));
			Object[] obj = new Object[4];
			obj[0] = pswd;
			obj[1] = pswdConfirm;
			obj[2] = newPswd;
			obj[3] = newPswdConfirm;
			page.setForm(obj);
			try {
				page = bidProjectManager.setPassword(page);
				return page;
			} catch (Exception e) {
				e.printStackTrace();
				page.setSuccess(false);
				page.setMsg("设置密码失败！");
				return page;
			}
		}
		page.setSuccess(false);
		page.setMsg("数据异常，请重新操作！");
		return page;
	}
	/**
	 * 
	 *@category 看有没有设过报价解密开始密码
	 *@author 邱磊
	 *@date 2015年8月21日 下午1:21:49
	 *@return firstSetPswd为true时表示没有设置过密码，需要设置
	 */
	@RequestMapping("/getPasswordInfo")
	@ResponseBody
	public BidProjectForm getPasswordInfo(){
		String projId = request.getParameter("projId");
		BidProjectForm form =null;
		try {
			form = bidProjectManager.getPasswordInfo(projId);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return form;
	}
	/**
	 * 
	 *@category 设置阶段时间时跳向输密码页面
	 *@author 邱磊
	 *@date 2015年8月21日 下午1:31:14
	 *@return
	 */
	@RequestMapping("/toCheckPassword")
	public String toCheckPassword(){
		String projId = request.getParameter("projId");
		BidProjectForm data = bidProjectManager.getPasswordInfo(projId);
		request.setAttribute("data", data);
		return "/pro/project/checkPassword";
	}
	/**
	 * 
	 *@category 验证密码，跳向设置各个阶段时间页面
	 *@author 邱磊
	 *@date 2015年8月21日 下午1:42:58
	 *@return
	 * @throws IOException 
	 */
	@RequestMapping("/toSetProjTime")
	public String toSetProjTime() throws IOException{
		String pass = request.getParameter("pass");
		String passwordCount = request.getParameter("passwordCount");
		String projId = request.getParameter("projId");
		request.setAttribute("projId", projId);
		request.setAttribute("oper", request.getParameter("oper"));
		request.setAttribute("pass", pass);
		if(StringUtils.isNotBlank(pass)){
			List<BidProjectForm> info = bidProjectManager.getSettimeDataDetail(projId);
			request.setAttribute("firstSetPswd", false);
			request.setAttribute("info", info);
			return "/pro/project/setProjTime";
		}
			
		String[] pswd = new String[ParseNumber.toInteger(passwordCount)];
		BidProjectForm form = bidProjectManager.getPasswordInfo(projId);
		if (StringUtils.isBlank(passwordCount)){
			request.setAttribute("errorMsg", "请求错误，请刷新！");
			return "/pro/project/checkPassword";
		}
		/*if (ParseNumber.toInteger(passwordCount) != form.getPasswordCount()){
			request.setAttribute("errorMsg", "输入密码个数，与所设密码个数不符！");
			return "/pro/project/checkPassword";
		}*/
		for (int i = 1; i <= ParseNumber.toInteger(passwordCount); i++){
			pswd[i-1] = request.getParameter("password"+i);
			if (StringUtils.isBlank(pswd[i-1])){
				request.setAttribute("errorMsg", "密码"+i+"不能为空！");
				BidProjectForm data = bidProjectManager.getPasswordInfo(projId);
				request.setAttribute("data", data);
				return "/pro/project/checkPassword";
			}
			switch (i){
			case 1:
				if (!DigestUtils.md5Hex(pswd[i-1]).equals(form.getPriceQuotePassword1())){
					request.setAttribute("errorMsg","密码"+i+"错误！");
					BidProjectForm data = bidProjectManager.getPasswordInfo(projId);
					request.setAttribute("data", data);
					return "/pro/project/checkPassword";
				}
				break;
			case 2:
				if (!DigestUtils.md5Hex(pswd[i-1]).equals(form.getPriceQuotePassword2())){
					request.setAttribute("errorMsg","密码"+i+"错误！");
					BidProjectForm data = bidProjectManager.getPasswordInfo(projId);
					request.setAttribute("data", data);
					return "/pro/project/checkPassword";
				}
				break;
			case 3:
				if (!DigestUtils.md5Hex(pswd[i-1]).equals(form.getPriceQuotePassword3())){
					request.setAttribute("errorMsg","密码"+i+"错误！");
					BidProjectForm data = bidProjectManager.getPasswordInfo(projId);
					request.setAttribute("data", data);
					return "/pro/project/checkPassword";
				}
				break;
			case 4:
				if (!DigestUtils.md5Hex(pswd[i-1]).equals(form.getPriceQuotePassword4())){
					request.setAttribute("errorMsg","密码"+i+"错误！");
					BidProjectForm data = bidProjectManager.getPasswordInfo(projId);
					request.setAttribute("data", data);
					return "/pro/project/checkPassword";
				}
				break;
			case 5:
				if (!DigestUtils.md5Hex(pswd[i-1]).equals(form.getPriceQuotePassword5())){
					request.setAttribute("errorMsg","密码"+i+"错误！");
					BidProjectForm data = bidProjectManager.getPasswordInfo(projId);
					request.setAttribute("data", data);
					return "/pro/project/checkPassword";
				}
				break;
			}
		}
		
		Map<String, Object> map = bidProjectManager.getDataDetail(projId);
		map.put("firstSetPswd", false);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		if(StringUtils.isNotBlank(user.getDefaultProjId())){
			request.setAttribute("defaultProjId", user.getDefaultProjId());
		}
		request.setAttribute("info", map);
		return "/pro/project/setProjTime";
	}
	
	/**
	 * 
	 *@category 验证密码，
	 *@author 邱磊
	 *@date 2015年8月21日 下午1:42:58
	 *@return
	 */
	@RequestMapping("/validatePassword")
	@ResponseBody
	public Pagination validatePassword(){
		Pagination page = new Pagination();
		String pass = request.getParameter("pass");
		String passwordCount = request.getParameter("passwordCount");
		String projId = request.getParameter("projId");
		
		if(StringUtils.isNotBlank(pass)){
			page.setSuccess(true);
			return page;
		}
			
		String[] pswd = new String[ParseNumber.toInteger(passwordCount)];
		BidProjectForm form = bidProjectManager.getPasswordInfo(projId);
		if (StringUtils.isBlank(passwordCount)){
			page.setMsg("请求错误，请刷新！");
			page.setSuccess(false);
			return page;
		}
		/*if (ParseNumber.toInteger(passwordCount) != form.getPasswordCount()){
			request.setAttribute("errorMsg", "输入密码个数，与所设密码个数不符！");
			return "/pro/project/checkPassword";
		}*/
		for (int i = 1; i <= ParseNumber.toInteger(passwordCount); i++){
			pswd[i-1] = request.getParameter("password"+i);
			if (StringUtils.isBlank(pswd[i-1])){
				page.setMsg("密码"+i+"不能为空！");
				page.setSuccess(false);
				return page;
			}
			switch (i){
			case 1:
				if (!DigestUtils.md5Hex(pswd[i-1]).equals(form.getPriceQuotePassword1())){
					page.setMsg("密码"+i+"错误！");
					page.setSuccess(false);
					return page;
				}
				break;
			case 2:
				if (!DigestUtils.md5Hex(pswd[i-1]).equals(form.getPriceQuotePassword2())){
					page.setMsg("密码"+i+"错误！");
					page.setSuccess(false);
					return page;
				}
				break;
			case 3:
				if (!DigestUtils.md5Hex(pswd[i-1]).equals(form.getPriceQuotePassword3())){
					page.setMsg("密码"+i+"错误！");
					page.setSuccess(false);
					return page;
				}
				break;
			case 4:
				if (!DigestUtils.md5Hex(pswd[i-1]).equals(form.getPriceQuotePassword4())){
					page.setMsg("密码"+i+"错误！");
					page.setSuccess(false);
					return page;
				}
				break;
			case 5:
				if (!DigestUtils.md5Hex(pswd[i-1]).equals(form.getPriceQuotePassword5())){
					page.setMsg("密码"+i+"错误！");
					page.setSuccess(false);
					return page;
				}
				break;
			}
		}
		
		page.setSuccess(true);
		return page;
	}
	/**
	 * @category 跳向设置时间页面
	 * @Auther xugp
	 * @date 2015年8月26日 下午3:01:15
	 * @return
	 * @return String
	 */
	@RequestMapping("/tosetProjTime")
	public String tosetProjTime(){
		logger.info("enter tosetProjTime method!");
		String projId = request.getParameter("projId");
		try {
			Map<String, Object> map = bidProjectManager.getDataDetail(projId);
			request.setAttribute("name", map.get("name"));
			List<BidProjectForm> info = bidProjectManager.getSettimeDataDetail(projId);
			request.setAttribute("projStart", info.get(0));
			request.setAttribute("projEnd", info.get(info.size()-1));
			info.remove(info.size()-1);
			info.remove(0);
			request.setAttribute("info", info);
			request.setAttribute("date", ParseDate.parseFullFormat(new Date()));
			request.setAttribute("projId", projId);
			request.setAttribute("oper", request.getParameter("oper"));
			SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
			String defalutProjId=  user.getDefaultProjId();
			if(StringUtils.isNotBlank(defalutProjId)){
				request.setAttribute("defalutProjId", defalutProjId);
			}
		} catch (Exception e) {
			e.printStackTrace();
			request.setAttribute("msg", "数据异常");
		}
		return "/pro/project/projectTimeSee";
	}
	
	/**
	 * 
	 *@category 设置项目招标各个阶段时间
	 *@author 邱磊
	 *@date 2015年8月21日 下午3:14:06
	 *@param form
	 *@return
	 */
	@RequestMapping("/setProjTime")
	@ResponseBody
	public Pagination setProjTime(BidProjectForm form){
		Pagination page = new Pagination();
		try {
			page = bidProjectManager.setProjTime(form,request);
			return page;
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
			page.setMsg("设置失败！");
			return page;
		}
	}
	
	/**
	 * 
	 * @category 跳向添加医疗机构页面
	 * @author 邱磊
	 * @date 2015年6月24日 上午9:42:55
	 * @param projId
	 * @param proName
	 * @return
	 */
	@RequestMapping("/toAddHospList")
	public String toAddHospList() {
		String projId = request.getParameter("projId");
		request.setAttribute("projId", projId);
		try {
			DicAreaForm area = dicAreaManager.getDicAreaById(province);
			request.setAttribute("area", area);
			String name = request.getParameter("name");
			if (StringUtils.isNotBlank(name)){
				name = new String(name.getBytes("ISO8859-1"),"utf-8");
			}
			request.setAttribute("name", name);
		} catch (Exception e) {
			logger.error(e.toString());
		}
		return "/pro/project/bidProjectAddHosp";
	}
	/**
	 * 
	 * @category 跳向添加招标项目目录
	 * @author 应晓川
	 * @date 2015年9月14日16:33:20
	 * @param projId
	 * @return
	 */
	@RequestMapping("/toAddDrugList")
	public String toAddDrugList() {
		String projId = request.getParameter("projId");
		String name="";
		try {
			 name = new String(request.getParameter("name").getBytes("ISO8859-1"),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} 
		request.setAttribute("name", name);
		request.setAttribute("projId", projId);
		return "/pro/project/bidProjectAddDrug";
	}
	
	/**
	 * 
	 * @category 获取添加招标项目目录
	 * @author 应晓川
	 * @date 2015年9月14日16:33:54
	 * @return
	 */
	@RequestMapping("/getAddDrugDataList")
	@ResponseBody
	public Pagination getAddDrugDataList() {
		Pagination page = new Pagination(request);
		DbUtil.jsonToMap(request, page);
		return bidProjectManager.getAddDrugDataList(page);
	}
	
	
	/**
	 * 
	 * @category 获取添加医疗机构列表数据
	 * @author 邱磊
	 * @date 2015年6月24日 上午9:43:20
	 * @return
	 */
	@RequestMapping("/getAddHospDataList")
	@ResponseBody
	public Pagination getAddHospDataList() {
		Pagination page = new Pagination(request);
		page.getConditions().put("area2", request.getParameter("area2"));
		page.getConditions().put("area3", request.getParameter("area3"));
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("hospName", request.getParameter("hospName"));
		page.getConditions().put("hospClassify", request.getParameter("hospClassify"));
		page.getConditions().put("hospCode", request.getParameter("hospCode"));
		page.getConditions().put("province", province);
		return bidProjectManager.getAddHospDataList(page);
	}
	/**
	 * 
	 * @category 批量添加医疗机构
	 * @author 邱磊
	 * @date 2015年6月24日 上午9:47:10
	 * @param array
	 * @return
	 */
	@RequestMapping("/batchAddHosp")
	@ResponseBody
	public Pagination batchAddHosp(String array) {
		Pagination page = new Pagination(request);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		page.getConditions().put("userId", user.getId());
		page.getConditions().put("projId", request.getParameter("projId"));
		try {
			if (array != null && !"".equals(array)) {
				Gson gson = new Gson();
				Type type = new TypeToken<List<HospInfo>>() {}.getType();
				List<HospInfo> list = gson.fromJson(array, type);
				if (list != null && !list.isEmpty()) {
					page.setRows(list);
					bidProjectManager.batchAddHosp(page);
					page.setSuccess(true);
				}
			}
		} catch (Exception e) {
			logger.error("批量添加医疗机构失败：", e);
			page.setSuccess(false);
		}
		return page;

	}
	/**
	 * @category 跳转到已添加医疗机构页面
	 * @author 邱磊
	 * @date   2015年7月9日
	 * @param  @param model
	 * @param  @param bidProject
	 * @param  @return
	 */
	@RequestMapping("/toHaveAddHospsList")
	public String toHaveAddHospsList(){
		request.setAttribute("projId", request.getParameter("projId"));
		String name = request.getParameter("name");
		try {
			if (StringUtils.isNotBlank(name)){
				name = new String(name.getBytes("ISO8859-1"),"utf-8");
			}
			request.setAttribute("name", name);
			DicAreaForm area = dicAreaManager.getDicAreaById(province);
			request.setAttribute("area", area);
			List<DicSys> hospCatList = DicSysUtil.getDicListByClassCode(Constants.HOSP_CAT);//医疗机构分类List
			List<DicSys> hospLevelList = DicSysUtil.getDicListByClassCode(Constants.HOSP_LEVEL);//医疗机构等级list
			request.setAttribute("hospCatList", hospCatList);
			request.setAttribute("hospLevelList", hospLevelList);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.toString());
		}
		return "/pro/project/bidProjhospHaveAddList";
	}
	/**
	 * 
	 *@category 获取已添加的医疗机构数据
	 *@author 邱磊
	 *@date 2015年8月18日 下午4:04:56
	 *@return
	 */
	@RequestMapping("/getHaveAddHospsList")
	@ResponseBody
	public Pagination getHaveAddHospsList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("area3", request.getParameter("area3"));
		page.getConditions().put("area2", request.getParameter("area2"));
		page.getConditions().put("hospName", request.getParameter("hospName"));
		page.getConditions().put("hospClassify", request.getParameter("hospClassify"));
		page.getConditions().put("hospCode", request.getParameter("hospCode"));
		page.getConditions().put("status", request.getParameter("status"));
		page.getConditions().put("hospLevel", request.getParameter("hospLevel"));
		return bidProjectManager.getHaveAddHospsList(page);
	}
	
	
	
	
	
	
	
	/**
	 * 
	 *@category 跳向日志查看页面
	 *@author 邱磊
	 *@date 2015年8月19日 下午2:10:53
	 *@return
	 */
	@RequestMapping("/toDetailLog")
	public String toDetailLog(){
		String projId = request.getParameter("projId");
		String updDatetime = request.getParameter("updDatetime");
		BidProjectDetailLogForm form = bidProjectManager.getDetailLog(projId, updDatetime);
		request.setAttribute("form", form);
		return "/pro/project/bidProjLogInfo";
	}
	
	/**
	 * 
	 * @category 跳向招标目录管理
	 * @author 徐国鹏
	 * @date 2015年9月7日 上午10:54:04
	 * @return
	 */
	@RequestMapping("/toBidProjectCheckList")
	public String toBidCatalogueList(RedirectAttributes attr) {
		SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
		String defalutProjId=  user.getDefaultProjId();
		if ( StringUtils.isNotBlank(defalutProjId) ) {
			BidProject bp=  bidProjectManager.getBidProjectById(defalutProjId);
			 attr.addAttribute("projId",defalutProjId);  
		     attr.addAttribute("name", bp.getName());
		     return "redirect:/bidProject/toHaveAddDrugQualityList.html";
		}
		return "/pro/project/bidProjectCheckList";
	}
	
	/**
	 * 
	 *@category 跳向已添加品规数
	 *@author 徐国鹏
	 *@date 2015年8月19日 上午10:38:13
	 *@return 
	 */
	@RequestMapping("/toHaveAddDrugQualityList")
	public String toHaveAddDrugQualityList(){
		request.setAttribute("projId", request.getParameter("projId"));
		String name = request.getParameter("name");
		try {
			if (StringUtils.isNotBlank(name)){
				name = new String(name.getBytes("ISO8859-1"),"utf-8");
			}
			request.setAttribute("name", name);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.toString());
		}
		return "/pro/project/bidHaveAddDrugQualityList";
	}
	
	/**
	 * 
	 *@category 跳向按目录导入药品列表页面
	 *@author 邱磊
	 *@date 2015年8月24日 下午2:51:02
	 *@return
	 */
	@RequestMapping("/toImportDrugByCatalog")
	public String toImportDrugByCatalog(){
		request.setAttribute("projId", request.getParameter("projId"));
		String name = request.getParameter("name");
		if (StringUtils.isNotBlank(name)){
			try {
				request.setAttribute("name", new String(name.getBytes("ISO8859-1"),"utf-8"));
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return "/pro/project/importDrugByCatalog";
	}
	/**
	 * 
	 *@category 获取药物目录列表数据
	 *@author 邱磊
	 *@date 2015年8月24日 下午3:02:18
	 *@return
	 */
	@RequestMapping("/getImportDrugByCatalogDataList")
	@ResponseBody
	public Pagination getImportDrugByCatalogDataList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("drugcatalogCode", request.getParameter("drugcatalogCode"));
		page.getConditions().put("drugcatalogName", request.getParameter("drugcatalogName"));
		page.getConditions().put("attribute", request.getParameter("attribute"));
		return bidProjectManager.getImportDrugByCatalogDataList(page);
	}
	/**
	 * 
	 *@category 按目录全部导入（已经存在的不忽略）
	 *@author 邱磊
	 *@date 2015年8月25日 上午10:33:47
	 *@return
	 */
	@RequestMapping("/importDrugByCatalog")
	@ResponseBody
	public Pagination importDrugByCatalog(){
		Pagination page = new Pagination();
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("drugcatalogId", request.getParameter("drugcatalogId"));
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		page.getConditions().put("userId", user.getId());
		try {
			bidProjectManager.importDrugByCatalog(page);
			page.setSuccess(true);
			return page;
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
			page.setMsg("导入失败！");
			return page;
		}
	}
	/**
	 * 
	 *@category 跳向按目录逐条导入页面
	 *@author 邱磊
	 *@date 2015年8月25日 上午11:04:43
	 *@return
	 */
	@RequestMapping("/toDrugByCatalogList")
	public String toDrugByCatalogList(){
		request.setAttribute("projId", request.getParameter("projId"));
		request.setAttribute("drugcatalogId", request.getParameter("drugcatalogId"));
		String drugcatalogName = request.getParameter("drugcatalogName");
		if (StringUtils.isNotBlank(drugcatalogName)){
			try {
				request.setAttribute("drugcatalogName", new String(drugcatalogName.getBytes("ISO8859-1"),"utf-8"));
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return "/pro/project/drugByCatalogList";
	}
	/**
	 * 
	 *@category 获取按药物目录逐条导入数据列表（排除已加入的）
	 *@author 邱磊
	 *@date 2015年8月25日 上午10:36:53
	 *@return
	 */
	@RequestMapping("/getDrugByCatalogDataList")
	@ResponseBody
	public Pagination getDrugByCatalogDataList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("drugcatalogId", request.getParameter("drugcatalogId"));
		page.getConditions().put("qualityspecCode", request.getParameter("qualityspecCode"));
		page.getConditions().put("qualityspecName", request.getParameter("qualityspecName"));
		return bidProjectManager.getDrugByCatalogDataList(page);
	}
	/**
	 * 
	 *@category 逐条导入药物目录药品
	 *@author 邱磊
	 *@date 2015年8月25日 下午1:11:27
	 *@return
	 */
	@RequestMapping("/importDrugByCatalogDetail")
	@ResponseBody
	public Pagination importDrugByCatalogDetail(){
		Pagination page = new Pagination();
		String array = request.getParameter("array");
		page.getConditions().put("projId", request.getParameter("projId"));
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		page.getConditions().put("userId", user.getId());
		if (StringUtils.isNotBlank(array)){
				Gson gson = new Gson();
				Type type = new TypeToken<List<BidProjectForm>>() {}.getType();
				List<BidProjectForm> list = gson.fromJson(array, type);
				if (list != null && list.size()>0) {
					page.setRows(list);
					try {
						bidProjectManager.importDrugByCatalogDetail(page);
						page.setSuccess(true);
					} catch (Exception e) {
						e.printStackTrace();
						page.setSuccess(false);
						page.setMsg("导入失败！");
						return page;
					}
					
				}else{
					page.setSuccess(false);
					page.setMsg("请选择要导入的药品");
					return page;
				}
				
		} else {
			page.setSuccess(false);
			page.setMsg("请选择要导入的药品！");
			return page;
		}
		return page;
		
	}
	/**
	 * 
	 *@category 跳向按品规添加药品
	 *@author 邱磊
	 *@date 2015年8月25日 下午2:06:38
	 *@return
	 */
	@RequestMapping("/toDrugqualityspecList")
	public String toDrugqualityspecList(){
		request.setAttribute("projId", request.getParameter("projId"));
		String name = request.getParameter("name");
		if (StringUtils.isNotBlank(name)){
			try {
				request.setAttribute("name", new String(name.getBytes("ISO8859-1"),"utf-8"));
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return "/pro/project/drugqualityspecList";
	}
	/**
	 * 
	 *@category 获取按品规导入列表
	 *@author 邱磊
	 *@date 2015年8月25日 下午2:10:41
	 *@return
	 */
	@RequestMapping("/getDrugqualityspecDataList")
	@ResponseBody
	public Pagination getDrugqualityspecDataList(){
		Pagination page = new Pagination(request);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		page.setForm(user.getDefaultProjId()); 
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("qualityspecCode", request.getParameter("qualityspecCode"));
		page.getConditions().put("qualityspecName", request.getParameter("qualityspecName"));
		return bidProjectManager.getDrugqualityspecDataList(page);
	}
	
	/**
	 * 
	 *@category 逐条导入药物目录药品
	 *@author 邱磊
	 *@date 2015年8月25日 下午1:11:27
	 *@return
	 */
	@RequestMapping("/importDrugqualityspec")
	@ResponseBody
	public Pagination importDrugqualityspec(){
		Pagination page = new Pagination();
		String array = request.getParameter("array");
		page.getConditions().put("projId", request.getParameter("projId"));
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		page.getConditions().put("userId", user.getId());
		if (StringUtils.isNotBlank(array)){
				Gson gson = new Gson();
				Type type = new TypeToken<List<BidProjectForm>>() {}.getType();
				List<BidProjectForm> list = gson.fromJson(array, type);
				if (list != null && list.size()>0) {
					page.setRows(list);
					try {
						bidProjectManager.importDrugqualityspec(page);
						page.setSuccess(true);
					} catch (Exception e) {
						e.printStackTrace();
						page.setSuccess(false);
						page.setMsg("导入失败！");
						return page;
					}
					
				}else{
					page.setSuccess(false);
					page.setMsg("请选择要导入的药品");
					return page;
				}
				
		} else {
			page.setSuccess(false);
			page.setMsg("请选择要导入的药品！");
			return page;
		}
		return page;
	}
	
	
	/**
	 * 
	 *@category 跳向已添加药品页面
	 *@author 邱磊
	 *@date 2015年8月19日 上午10:38:13
	 *@return 
	 */
	@RequestMapping("/toHaveAddDrugList")
	public String toHaveAddDrugList(){
		request.setAttribute("projId", request.getParameter("projId"));
		String name = request.getParameter("name");
		try {
			if (StringUtils.isNotBlank(name)){
				name = new String(name.getBytes("ISO8859-1"),"utf-8");
			}
			request.setAttribute("name", name);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.toString());
		}
		return "/pro/project/bidProjHaveAddDrugList";
	}
	/**
	 * 
	 *@category 获取已添加药品数据
	 *@author 邱磊
	 *@date 2015年8月19日 上午10:39:32
	 *@return 
	 */
	@RequestMapping("/getHaveAddDrugDataList")
	@ResponseBody
	public Pagination getHaveAddDrugDataList(){
		Pagination page = new Pagination(request);
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		page.setForm(user.getDefaultProjId());
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("qualityspecCode", request.getParameter("qualityspecCode"));
		page.getConditions().put("qualityspecName", request.getParameter("qualityspecName"));
		page.getConditions().put("drugcatalogName", request.getParameter("drugcatalogName"));
		return bidProjectManager.getHaveAddDrugDataList(page);
	}
	/**
	 * 
	 *@category 启用停用已添加的药品（批量）
	 *@author 邱磊
	 *@date 2015年8月19日 上午10:34:00
	 *@param array
	 *@return 
	 */
	@RequestMapping("/batchSwitchDrugStatus")
	@ResponseBody
	public Pagination batchSwitchDrugStatus(String array){
		Pagination page = new Pagination();
//		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("status", request.getParameter("status"));
		if (StringUtils.isNotBlank(array)){
			Gson gson = new Gson();
			Type type = new TypeToken<List<BidProjectForm>>() {}.getType();
			List<BidProjectForm> list = gson.fromJson(array, type);
			if (list != null && list.size()>0) {
				page.setRows(list);
				try {
					bidProjectManager.batchSwitchDrugStatus(page);
					page.setSuccess(true);
				} catch (Exception e) {
					e.printStackTrace();
					page.setSuccess(false);
					page.setMsg("操作失败！");
					return page;
				}
			}else{
				page.setSuccess(false);
				page.setMsg("请选择要操作的数据！");
				return page;
			}
			
		} else {
			page.setSuccess(false);
			page.setMsg("请选择要操作的数据！");
			return page;
		}
		return page;
	}
	
	
	/**
	 * 
	 *@category 关闭当前节点
	 *@author 邱磊
	 *@date 2015年8月26日 下午1:17:00
	 *@return
	 */
	@RequestMapping("/closePoint")
	@ResponseBody
	public Pagination closePoint(){
		Pagination page = new Pagination();
		String point = request.getParameter("point");
		String projId = request.getParameter("projId");
		try {
			bidProjectManager.closePoint(point, projId);
			page.setSuccess(true);
			return page;
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
			page.setMsg("关闭失败！");
			return page;
		}
	}
	/**
	 * 
	 *@category 开启节点
	 *@author 邱磊
	 *@date 2015年8月26日 下午1:17:00
	 *@return
	 */
	@RequestMapping("/openPoint")
	@ResponseBody
	public Pagination openPoint(){
		Pagination page = new Pagination();
		String point = request.getParameter("point");
		String projId = request.getParameter("projId");
		try {
			bidProjectManager.openPoint(point, projId);
			page.setSuccess(true);
			return page;
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
			page.setMsg("关闭失败！");
			return page;
		}
	}
	/**
	 * 
	 *@category 跳向资质审核项目列表页面
	 *@author 邱磊
	 *@date 2015年8月27日 上午8:50:11
	 *@return
	 */
	@RequestMapping("/toAuditCompprofileProjList")
	public String toAuditCompprofileProjList(){
		return "/pro/project/auditCompprofileProjList";
	}
	/**
	 * 
	 *@category 跳向项目中已申报资质的企业列表页面
	 *@author 邱磊
	 *@date 2015年8月27日 上午9:05:43
	 *@return
	 */
	@RequestMapping("/toCompprofileCompList")
	public String toCompprofileCompList(RedirectAttributes attr){
		List<Object> list = bidProjectManager.getSelectProjList();
		request.setAttribute("projList", list);
		return "/pro/project/compprofileCompList";
	}
	/**
	 * 
	 *@category 获取项目中已申报资质的企业列表
	 *@author 邱磊
	 *@date 2015年8月27日 上午9:10:11
	 *@return
	 */
	@RequestMapping("/getCompprofileCompDataList")
	@ResponseBody
	public Pagination getCompprofileCompDataList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("compName", request.getParameter("compName"));
		page.getConditions().put("compType", request.getParameter("compType"));
		SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
		String defalutProjId=  user.getDefaultProjId();
		if(StringUtils.isNotBlank(defalutProjId)){
			page.getConditions().put("projId", defalutProjId);
			page.setForm(defalutProjId);
		}
		return bidProjectManager.getCompprofileCompDataList(page);
	}
	/**
	 * 
	 *@category 跳向企业资质审核页面
	 *@author 邱磊
	 *@date 2015年9月1日 上午11:49:53
	 *@return
	 */
	@RequestMapping("/toAuditCompprofileCompList")
	public String toAuditCompprofileCompList(){
		List<Object> list = bidProjectManager.getSelectProjList();
		request.setAttribute("projList", list);
		request.setAttribute("date",DateUtil.date(new Date()));
		return "/pro/project/auditCompprofileCompList";
	}
	/**
	 * 
	 *@category 跳向企业资质详情页面
	 *@author 邱磊
	 *@date 2015年8月27日 上午10:24:55
	 *@return
	 */
	@RequestMapping("/toCompprofileDetail")
	public String toCompprofileDetail(){
		return "/pro/project/compprofileDetail";
	}
	/**
	 * 
	 *@category 跳向企业资质查看页面
	 *@author 徐国鹏
	 *@date 2015年9月7日 上午10:24:55
	 *@return
	 */
	@RequestMapping("/toCompprofileDetailList")
	public String toCompprofileDetailList(){
		return "/pro/project/compprofileDetailList";
	}
	/**
	 * 
	 *@category 跳向企业审核资质详情页面
	 *@author 徐国鹏
	 *@date 2015年8月27日 上午10:24:55
	 *@return
	 */
	@RequestMapping("/toCompprofileAuditDetail")
	public String toCompprofileAuditDetail(){
		return "/pro/project/compprofileAuditDetail";
	}
	/**
	 * 
	 *@category 跳向审核页面
	 *@author 邱磊
	 *@date 2015年8月27日 上午11:09:20
	 *@return
	 */
	@RequestMapping("/compprofileAudit")
	public String toAddCompprofileAudit(){
		return "/pro/project/compprofileAudit";
	}
	/**
	 * 
	 *@category 跳向澄清查看页面（企业列表）
	 *@author 邱磊
	 *@date 2015年8月27日 上午11:09:35
	 *@return
	 */
	@RequestMapping("/toComplainCompprofileList")
	public String toComplainCompprofileList(){
		List<Object> list = bidProjectManager.getSelectProjList();
		request.setAttribute("projList", list);
		return "/pro/project/complainCompprofileCompList";
	}
	/**
	 * 
	 *@category 跳向企业资质详情页面
	 *@author 徐国鹏
	 *@date 2015年9月6日 上午10:24:55
	 *@return
	 */
	@RequestMapping("/toCompprofileDetailAudit")
	public String toCompprofileDetailAudit(){
		return "/pro/project/compprofileDetailAudit";
	}
	/**
	 * 
	 *@category 跳向澄清审核页面（企业列表）
	 *@author 邱磊
	 *@date 2015年8月27日 上午11:09:35
	 *@return
	 */
	@RequestMapping("/toComplainCompprofileAuditList")
	public String toComplainCompprofileAuditList(){
		List<Object> list = bidProjectManager.getSelectProjList();
		request.setAttribute("projList", list);
		request.setAttribute("date",DateUtil.date(new Date()));
		return "/pro/project/complainCompprofileAuditList";
	}
	/**
	 * 
	 *@category 跳向澄清审核页面
	 *@author 邱磊
	 *@date 2015年8月27日 上午11:09:35
	 *@return
	 */
	@RequestMapping("/toComplainCompprofileAudit")
	public String toComplainCompprofileAudit(){
		return "/pro/project/complainCompprofileAudit";
	}
	/**
	 * 
	 *@category 获取企业资质详情
	 *@author 邱磊
	 *@date 2015年8月27日 下午5:10:14
	 *@return
	 */
	@RequestMapping("/getCompprofileDetail")
	@ResponseBody
	public Pagination getCompprofileDetail(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("compId", request.getParameter("compId"));
		page.getConditions().put("applyType", request.getParameter("applyType"));
		page.getConditions().put("auditStatus", request.getParameter("auditStatus"));
		page.getConditions().put("complainStatus", request.getParameter("complainStatus"));
		page.setSuccess(true);
		return bidProjectManager.getCompprofileDetail(page);
	}
	/**
	 * 
	 *@category 审核企业资质
	 *@author 邱磊
	 *@date 2015年8月27日 下午1:35:55
	 *@return
	 */
	@RequestMapping("/auditCompprofile")
	@ResponseBody
	public Pagination auditCompprofile(){
		Pagination page = new Pagination();
		page.getConditions().put("projCompprofileId", request.getParameter("projCompprofileId"));
		page.getConditions().put("auditStatus", request.getParameter("auditStatus"));
		page.getConditions().put("auditRemark", request.getParameter("auditRemark"));
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		page.getConditions().put("userId", user.getId());
		try {
			bidProjectManager.auditCompprofile(page);
			page.setSuccess(true);
			return page;
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
			page.setMsg("审核失败！");
			return page;
		}
	}
	/**
	 * 
	 *@category 澄清审核企业资质
	 *@author 邱磊
	 *@date 2015年8月27日 下午1:35:55
	 *@return
	 */
	@RequestMapping("/auditCompprofileAudit")
	@ResponseBody
	public Pagination auditCompprofileAudit(){
		Pagination page = new Pagination();
		page.getConditions().put("projCompprofileId", request.getParameter("projCompprofileId"));
		page.getConditions().put("complainStatus", request.getParameter("complainStatus"));
		page.getConditions().put("complainRemark", request.getParameter("complainRemark"));
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		page.getConditions().put("userId", user.getId());
		try {
			bidProjectManager.auditCompprofileAudit(page);
			page.setSuccess(true);
			return page;
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
			page.setMsg("审核失败！");
			return page;
		}
	}
	/**
	 * 
	 *@category 跳向申报药品的生产企业列表
	 *@author 邱磊
	 *@date 2015年8月28日 上午9:36:53
	 *@return
	 */
	@RequestMapping("/toDeclareDrugByCompList")
	public String toDeclareDrugByCompList(){
		request.setAttribute("projId", request.getParameter("projId"));
		return "/pro/project/declareDrugByCompList";
	}
	/**
	 * 
	 *@category 获取申报药品的生产企业列表数据
	 *@author 邱磊
	 *@date 2015年8月28日 上午9:47:29
	 *@return
	 */
	@RequestMapping("/getDeclareDrugByCompDataList")
	@ResponseBody
	public Pagination getDeclareDrugByCompDataList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("compCode", request.getParameter("compCode"));
		page.getConditions().put("compName", request.getParameter("compName"));
		page.getConditions().put("areaName", request.getParameter("areaName"));
		page.getConditions().put("fatherArea", request.getParameter("fatherArea"));
		return bidProjectManager.getDeclareDrugByCompDataList(page);
	}
	/**
	 * 
	 *@category 跳向企业申报的项品列表
	 *@author 邱磊
	 *@date 2015年8月28日 上午10:11:19
	 */
	@RequestMapping("/toCompDeclareDrugList")
	public String toCompDeclareDrugList(){
		request.setAttribute("projId", request.getParameter("projId"));
		return "/pro/project/compDeclareDrugList";
	}
	/**
	 * 
	 *@category 获取企业申报的项品列表数据
	 *@author 邱磊
	 *@date 2015年8月28日 上午10:26:54
	 *@return
	 */
	@RequestMapping("/getCompDeclareDrugDataList")
	@ResponseBody
	public Pagination getCompDeclareDrugDataList(){
		Pagination page = new Pagination();
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("compId", request.getParameter("compId"));
		page.getConditions().put("drugCode", request.getParameter("drugCode"));
		page.getConditions().put("drugName", request.getParameter("drugName"));
		return bidProjectManager.getCompDeclareDrugList(page);
	}
	/**
	 * 
	 *@category 跳向药品资质详情页面
	 *@author 邱磊
	 *@date 2015年8月28日 下午1:38:20
	 *@return
	 */
	@RequestMapping("/toDrugCompprofileDetail")
	public String toDrugCompprofileDetail(){
		return "/pro/project/drugCompprofileDetail";
	}
	/**
	 * 
	 *@category 获取药品资质详情
	 *@author 邱磊
	 *@date 2015年8月28日 下午1:57:29
	 *@return
	 */
	@RequestMapping("/getDrugCompprofileDetail")
	@ResponseBody
	public Pagination getDrugCompprofileDetail(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projProddrugId", request.getParameter("projProddrugId"));
		page.getConditions().put("profileCode", request.getParameter("profileCode"));
		page.getConditions().put("profileName", request.getParameter("profileName"));
		page.getConditions().put("auditStatus", request.getParameter("auditStatus"));
		page.getConditions().put("complainStatus", request.getParameter("complainStatus"));
		page.setSuccess(true);
		return bidProjectManager.getDrugCompprofileDetail(page);
	}
	/**
	 * 
	 *@category 跳向药品资质审核页面
	 *@author 邱磊
	 *@date 2015年8月28日 下午1:38:20
	 *@return
	 */
	@RequestMapping("/toDrugCompprofileAudit")
	public String toDrugCompprofileAudit(){
		return "/pro/project/drugCompprofileAudit";
	}
	/**
	 * 
	 *@category 跳向药品澄清审核页面
	 *@author 邱磊
	 *@date 2015年8月28日 下午1:38:20
	 *@return
	 */
	@RequestMapping("/toDrugCompprofileDetailAudit")
	public String toDrugCompprofileDetailAudit(){
		return "/pro/project/drugCompprofileDetailAudit";
	}
	/**
	 * 
	 *@category 审核药品资质
	 *@author 邱磊
	 *@date 2015年8月28日 下午2:33:52
	 *@return
	 */
	@RequestMapping("/auditDrugCompprofile")
	@ResponseBody
	public Pagination auditDrugCompprofile(){
		Pagination page = new Pagination();
		page.getConditions().put("bidCompdrugprofileId", request.getParameter("bidCompdrugprofileId"));
		page.getConditions().put("auditStatus", request.getParameter("auditStatus"));
		page.getConditions().put("auditRemark", request.getParameter("auditRemark"));
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		page.getConditions().put("userId", user.getId());
		try {
			bidProjectManager.auditDrugCompprofile(page);
			page.setSuccess(true);
			return page;
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
			page.setMsg("审核失败！");
			return page;
		}
	}
	
	/**
	 * 
	 *@category 审核药品资质澄清
	 *@author 邱磊
	 *@date 2015年8月28日 下午2:33:52
	 *@return
	 */
	@RequestMapping("/auditComplianDrugCompprofile")
	@ResponseBody
	public Pagination auditComplianDrugCompprofile(){
		Pagination page = new Pagination();
		page.getConditions().put("bidCompdrugprofileId", request.getParameter("bidCompdrugprofileId"));
		page.getConditions().put("complainStatus", request.getParameter("complainStatus"));
		page.getConditions().put("complainAuditRemark", request.getParameter("complainAuditRemark"));
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		page.getConditions().put("userId", user.getId());
		try {
			bidProjectManager.auditComplianDrugCompprofile(page);
			page.setSuccess(true);
			return page;
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
			page.setMsg("审核失败！");
			return page;
		}
	}
	/**
	 * 
	 *@category 跳向按药品审核药品资质页面
	 *@author 邱磊
	 *@date 2015年8月29日 下午2:11:27
	 *@return
	 */
	@RequestMapping("/toAuditDrugCompprofileByDrugList")
	public String toAuditDrugCompprofileByDrugList(){
		return "/pro/project/auditDrugCompprofileByDrugList";
	}
	/**
	 * 
	 *@category 获取按药品审核药品资质列表数据
	 *@author 邱磊
	 *@date 2015年8月29日 下午2:41:17
	 *@return
	 */
	@RequestMapping("/getAuditDrugCompprofileByDrugList")
	@ResponseBody
	public Pagination getAuditDrugCompprofileByDrugList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("drugCode", request.getParameter("drugCode"));
		page.getConditions().put("qualityspecName", request.getParameter("qualityspecName"));
		page.getConditions().put("compCode", request.getParameter("compCode"));
		page.getConditions().put("compName", request.getParameter("compName"));
		return bidProjectManager.getAuditDrugCompprofileByDrugList(page);
	}
	/**
	 * 
	 *@category 跳向按药品资质审核页面
	 *@author 邱磊
	 *@date 2015年8月28日 下午1:38:20
	 *@return
	 */
	@RequestMapping("/toAuditDrugCompprofileAudit")
	public String toAuditDrugCompprofileAudit(){
		return "/pro/project/auditdrugCompprofileAudit";
	}
	/**
	 * 
	 *@category 跳向按药品澄清审核页面
	 *@author 邱磊
	 *@date 2015年8月28日 下午1:38:20
	 *@return
	 */
	@RequestMapping("/toAuditDrugCompprofileDetailAudit")
	public String toAuditDrugCompprofileDetailAudit(){
		return "/pro/project/auditdrugCompprofileDetailAudit";
	}
	/**
	 * 
	 *@category 审核申报药品
	 *@author 邱磊
	 *@date 2015年8月31日 上午11:55:38
	 *@return
	 */
	@RequestMapping("/auditDrug")
	@ResponseBody
	public Pagination auditDrug(){
		Pagination page = new Pagination();
		String array = request.getParameter("array");
		if (StringUtils.isNotBlank(array)){
			Gson gson = new Gson();
			Type type = new TypeToken<List<BidProjectForm>>() {}.getType();
			List<BidProjectForm> list = gson.fromJson(array, type);
			SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
			if (list != null && !list.isEmpty()) {
				try {
					page.setRows(list);
					page.getConditions().put("auditStatus", request.getParameter("auditStatus"));
					page.getConditions().put("auditRemark", request.getParameter("auditRemark"));
					page.getConditions().put("userId", user.getId());
					bidProjectManager.auditDrug(page);
					page.setSuccess(true);
				} catch (Exception e) {
					e.printStackTrace();
					page.setMsg("操作失败！");
					page.setSuccess(false);
					return page;
				}
				return page;
			} else {
				page.setSuccess(false);
				page.setMsg("请选择要审核的数据！");
				return page;
			}
		} else {
			page.setSuccess(false);
			page.setMsg("请选择要审核的数据！");
			return page;
		}
	}
	/**
	 * 
	 *@category 澄清审核申报药品
	 *@author 邱磊
	 *@date 2015年8月31日 上午11:55:38
	 *@return
	 */
	@RequestMapping("/auditComplainDrug")
	@ResponseBody
	public Pagination auditComplainDrug(){
		Pagination page = new Pagination();
		String array = request.getParameter("array");
		if (StringUtils.isNotBlank(array)){
			Gson gson = new Gson();
			Type type = new TypeToken<List<BidProjectForm>>() {}.getType();
			List<BidProjectForm> list = gson.fromJson(array, type);
			SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
			if (list != null && !list.isEmpty()) {
				try {
					page.setRows(list);
					page.getConditions().put("complainStatus", request.getParameter("complainStatus"));
					page.getConditions().put("complainAuditRemark", request.getParameter("complainAuditRemark"));
					page.getConditions().put("userId", user.getId());
					bidProjectManager.auditComplainDrug(page);
					page.setSuccess(true);
				} catch (Exception e) {
					e.printStackTrace();
					page.setMsg("操作失败！");
					page.setSuccess(false);
					return page;
				}
				return page;
			} else {
				page.setSuccess(false);
				page.setMsg("请选择要审核的数据！");
				return page;
			}
		} else {
			page.setSuccess(false);
			page.setMsg("请选择要审核的数据！");
			return page;
		}
	}
	/**
	 * 
	 *@category 跳向公示详情页面
	 *@author 邱磊
	 *@date 2015年8月31日 下午5:32:55
	 *@return
	 */
	public String toPubSettingDetail(){
		return "/pro/project/pubSettingDetail";
	}
	/**
	 * 
	 *@category 获取公示详情
	 *@author 邱磊
	 *@date 2015年8月31日 下午5:34:11
	 *@return
	 */
	@RequestMapping("/getPubSettingDetail")
	@ResponseBody
	public List<Map<String, Object>> getPubSettingDetail(){
		String projId = request.getParameter("projId");
		return bidProjectManager.getPubSettingDetail(projId);
	}
	/**
	 * 
	 *@category 跳向新增公示页面
	 *@author 邱磊
	 *@date 2015年8月31日 下午6:27:59
	 *@return
	 */
	@RequestMapping("/toAddSetting")
	@ResponseBody
	public String toAddSetting(){
		request.setAttribute("projId", request.getParameter("projId"));
		return "/pro/project/addSetting";
	}
	/**
	 * 
	 *@category 新增公示
	 *@author 邱磊
	 *@date 2015年8月31日 下午6:08:05
	 *@return
	 */
	@RequestMapping("/addSetting")
	@ResponseBody
	public Pagination addSetting(BidPubSettings form){
		Pagination page = new Pagination();
		SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
		form.setScriptSubmitUser(user.getId());
		form.setUpdUser(user.getId());
		try {
			bidProjectManager.addSetting(form);
			page.setSuccess(true);
		} catch (Exception e) {
			e.printStackTrace();
			page.setSuccess(false);
			page.setMsg("添加失败！");
			return page;
		}
		return page;
	}
	
//	public String toViewSetting(){
//		Pagination page = new Pagination();
//		
//	}
	
	/**
	 * 
	 *@category 跳向投标药品数页面
	 *@author 应晓川	
	 *@date 2015年9月14日19:43:22
	 *@return
	 */
	@RequestMapping("/toProjDrugList")
	public String toProjDrugList(){
		String name = request.getParameter("name");
		if (StringUtils.isNotBlank(name)){
			try {
				name = new String(name.getBytes("ISO8859-1"),"utf-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		request.setAttribute("name",name);
		request.setAttribute("projId",request.getParameter("projId"));
		return "/pro/project/projDrugList";
	}
	
	/**
	 * 
	 *@category 获取投标药品数数据
	 *@author 应晓川
	 *@date 2015年9月14日19:58:19
	 *@return
	 */
	@RequestMapping("/getProjDrugList")
	@ResponseBody
	public Pagination getProjDrugList(){
		Pagination page = new Pagination(request);
		DbUtil.jsonToMap(request, page);
		return bidProjectManager.getProjDrugList(page);
	}
	
	/**
	 * 
	 *@category 跳向生产企业已申报药品页面
	 *@author 邱磊 	
	 *@date 2015年9月2日 下午1:35:19
	 *@return
	 */
	@RequestMapping("/toDeclareDrugList")
	public String toDeclareDrugList(){
		List<Map<String, Object>> list = bidProjectManager.getProjList();
		request.setAttribute("list", list);
		List<DicSys> projCatList = DicSysUtil.getDicListByClassCode(Constants.PROJ_CAT);
		request.setAttribute("projCatList",projCatList);
		return "/pro/project/declareDrugList";
	}
	/**
	 * 
	 *@category 获取生产企业已申报的药品（药品招标管理--投标药品信息管理--药品查看）
	 *@author 邱磊
	 *@date 2015年9月2日 下午1:58:38
	 *@return
	 */
	@RequestMapping("/getDeclareDrugDataList")
	@ResponseBody
	public Pagination getDeclareDrugDataList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("drugCode", request.getParameter("drugCode"));
		page.getConditions().put("qualityspecName", request.getParameter("qualityspecName"));
		page.getConditions().put("compName", request.getParameter("compName"));
		page.getConditions().put("projCat", request.getParameter("projCat"));
		page.getConditions().put("auditStatus", request.getParameter("auditStatus"));
		page.getConditions().put("complainStatus", request.getParameter("complainStatus"));
		page.getConditions().put("auditType", request.getParameter("auditType"));
		SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
		String defalutProjId=  user.getDefaultProjId();
		if(StringUtils.isNotBlank(defalutProjId)){
			page.getConditions().put("projId", defalutProjId);
			page.setForm(defalutProjId);
		}
		return bidProjectManager.getDeclareDrugDataList(page);
	}
	/**
	 * 
	 *@category 跳向药品审核页面（药品招标管理--投标药品信息管理--药品审核）
	 *@author 邱磊
	 *@date 2015年9月2日 下午3:29:25
	 *@return
	 */
	@RequestMapping("/toDeclareDrugAuditList")
	public String toDeclareDrugAuditList(){
		List<Map<String, Object>> list = bidProjectManager.getProjList();
		request.setAttribute("list", list);
		List<DicSys> projCatList = DicSysUtil.getDicListByClassCode(Constants.PROJ_CAT);
		request.setAttribute("projCatList",projCatList);
		return "/pro/project/declareDrugAuditList";
	}
	/**
	 * 
	 *@category 跳向药品澄清查看页面（药品招标管理--投标药品信息管理--药品澄清查看）
	 *@author 邱磊
	 *@date 2015年9月2日 下午3:29:25
	 *@return
	 */
	@RequestMapping("/toDeclareDrugComplainList")
	public String toDeclareDrugComplainList(){
		List<Map<String, Object>> list = bidProjectManager.getProjList();
		request.setAttribute("list", list);
		List<DicSys> projCatList = DicSysUtil.getDicListByClassCode(Constants.PROJ_CAT);
		request.setAttribute("projCatList",projCatList);
		return "/pro/project/declareDrugComplainList";
	}
	/**
	 * 
	 *@category 跳向药品澄清查看页面
	 *@author 邱磊
	 *@date 2015年8月28日 下午1:38:20
	 *@return
	 */
	@RequestMapping("/toDeclareDrugComplainListAudit")
	public String toDeclareDrugComplainListAudit(){
		return "/pro/project/declareDrugComplainListAudit";
	}
	/**
	 * 
	 *@category 跳向药品澄清审核页面（药品招标管理--投标药品信息管理--药品澄清审核）
	 *@author 邱磊
	 *@date 2015年9月2日 下午3:29:25
	 *@return
	 */
	@RequestMapping("/toDeclareDrugComplainAuditList")
	public String toDeclareDrugComplainAuditList(){
		List<Map<String, Object>> list = bidProjectManager.getProjList();
		request.setAttribute("list", list);
		List<DicSys> projCatList = DicSysUtil.getDicListByClassCode(Constants.PROJ_CAT);
		request.setAttribute("projCatList",projCatList);
		return "/pro/project/declareDrugComplainAuditList";
	}
	/**
	 * 
	 *@category 跳向药品资质查看页面（药品招标管理--投标药品信息管理--药品资质查看）
	 *@author 邱磊
	 *@date 2015年9月2日 下午3:29:25
	 *@return
	 */
	@RequestMapping("/toDrugCompprofileList")
	public String toDrugCompprofileList(){
		List<Map<String, Object>> list = bidProjectManager.getProjList();
		request.setAttribute("list", list);
		List<DicSys> projCatList = DicSysUtil.getDicListByClassCode(Constants.PROJ_CAT);
		request.setAttribute("projCatList",projCatList);
		return "/pro/project/drugCompprofileList";
	}
	/**
	 * 
	 *@category 跳向药品资质查看页面（药品招标管理--投标药品信息管理--药品资质审核）
	 *@author 徐国鹏
	 *@date 2015年9月2日 下午3:29:25
	 *@return
	 */
	@RequestMapping("/toDrugCompprofileListAudit")
	public String toDrugCompprofileListAudit(){
		List<Map<String, Object>> list = bidProjectManager.getProjList();
		request.setAttribute("list", list);
		List<DicSys> projCatList = DicSysUtil.getDicListByClassCode(Constants.PROJ_CAT);
		request.setAttribute("projCatList",projCatList);
		return "/pro/project/drugCompprofileListAudit";
	}
	/**
	 * 
	 *@category 跳向药品资质查看页面（药品招标管理--投标药品信息管理--药品资质澄清查看）
	 *@author 徐国鹏
	 *@date 2015年9月2日 下午3:29:25
	 *@return
	 */
	@RequestMapping("/toDrugCompprofileListProfileAudit")
	public String toDrugCompprofileListProfileAudit(){
		List<Map<String, Object>> list = bidProjectManager.getProjList();
		request.setAttribute("list", list);
		List<DicSys> projCatList = DicSysUtil.getDicListByClassCode(Constants.PROJ_CAT);
		request.setAttribute("projCatList",projCatList);
		return "/pro/project/drugCompprofileListProfileAudit";
	}
	/**
	 * 
	 *@category 跳向药品资质查看页面（药品招标管理--投标药品信息管理--药品澄清审核）
	 *@author 徐国鹏
	 *@date 2015年9月2日 下午3:29:25
	 *@return
	 */
	@RequestMapping("/toDrugCompprofileClarifyAudit")
	public String toDrugCompprofileClarifyAudit(){
		List<Map<String, Object>> list = bidProjectManager.getProjList();
		request.setAttribute("list", list);
		List<DicSys> projCatList = DicSysUtil.getDicListByClassCode(Constants.PROJ_CAT);
		request.setAttribute("projCatList",projCatList);
		return "/pro/project/drugCompprofileClarifyAudit";
	}
	/**
	 * 
	 *@category 获取已申报药品资质的药品
	 *@author 邱磊
	 *@date 2015年9月2日 下午4:04:53
	 *@return
	 */
	@RequestMapping("/getDrugCompprofileList")
	@ResponseBody
	public Pagination getDrugCompprofileList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("drugCode", request.getParameter("drugCode"));
		page.getConditions().put("qualityspecName", request.getParameter("qualityspecName"));
		page.getConditions().put("compName", request.getParameter("compName"));
		page.getConditions().put("projCat", request.getParameter("projCat"));
		page.getConditions().put("auditStatus", request.getParameter("auditStatus"));
		page.getConditions().put("complainStatus", request.getParameter("complainStatus"));
		page.getConditions().put("auditType", request.getParameter("auditType"));
		page.getConditions().put("fStatsu", request.getParameter("fStatsu"));//资质状态
		page.getConditions().put("fCStatsu", request.getParameter("cStatsu"));//资质澄清状态
		SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
		String defalutProjId=  user.getDefaultProjId();
		if(StringUtils.isNotBlank(defalutProjId)){
			page.getConditions().put("projId", defalutProjId);
			page.setForm(defalutProjId);
		}
		page.setSuccess(true);
		return bidProjectManager.getDrugCompprofileList(page);
	}
	/**
	 * 
	 *@category 跳向查看哪些生产企业报名页面（药品招标管理--采购项目管理--招标项目查看<点击生产企业数量>）
	 *@author 邱磊
	 *@date 2015年9月7日 上午10:50:19
	 *@return
	 */
	@RequestMapping("/toJoinProCompList")
	public String toJoinProCompList(){
		String name = request.getParameter("name");
		if (StringUtils.isNotBlank(name)){
			try {
				name = new String(name.getBytes("ISO8859-1"),"utf-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		request.setAttribute("name", name);
		return "/pro/project/joinProCompList";
	}
	/**
	 * 
	 *@category 获取报名的生产企业列表
	 *@author 邱磊
	 *@date 2015年9月7日 上午10:55:38
	 *@return
	 */
	@RequestMapping("/getJoinProCompDataList")
	@ResponseBody
	public Pagination getJoinProCompDataList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("compCode", request.getParameter("compCode"));
		page.getConditions().put("compName", request.getParameter("compName"));
		page.getConditions().put("area1", request.getParameter("area1"));
		page.getConditions().put("area2", request.getParameter("area2"));
		page.getConditions().put("area3", request.getParameter("area3"));
		return bidProjectManager.getJoinProCompDataList(page);
	}
	/**
	 * 
	 *@category 跳向中标药品页面 （药品招标管理--采购项目管理--招标项目查看<点击生中标药品数量>）
	 *@author 邱磊
	 *@date 2015年9月7日 下午1:44:53
	 *@return
	 */
	@RequestMapping("/toBindDrugsList")
	public String toBindDrugsList(){
		String name = request.getParameter("name");
		if (StringUtils.isNotBlank(name)){
			try {
				name = new String(name.getBytes("ISO8859-1"),"utf-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		request.setAttribute("name", name);
		return "/pro/project/bindDrugsList";
	}
	/**
	 * 
	 *@category 获取中标药品数据列表
	 *@author 邱磊
	 *@date 2015年9月7日 下午1:50:50
	 *@return
	 */
	@RequestMapping("/getBindDrugsDataList")
	@ResponseBody
	public Pagination getBindDrugsDataList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("compName", request.getParameter("compName"));
		page.getConditions().put("drugCode", request.getParameter("drugCode"));
		page.getConditions().put("qualityspecName", request.getParameter("qualityspecName"));
		return bidProjectManager.getBindDrugsDataList(page);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	/**
	 * @category 进入添加配送企业页面
	 * @auth 单大伟
	 * @param model
	 * @param bidProject
	 * @return
	 * @date 2015年6月13日
	 */
	@RequestMapping("/toCompList")
	public String toCompList(Model model, BidProject bidProject) {
		bidProject.setProjId(request.getParameter("projIdAddcomp"));
		model.addAttribute("bidProject", bidProjectManager.getBidProjectById(bidProject.getProjId()));
		return "/pro/project/bidProjectCompsEdit";
	}

	/**
	 * 
	 * @category 获取非项目配送企业列表Json
	 * @auth 单大伟
	 * @param projId
	 * @return
	 * @date 2015年6月11日
	 */
	@ResponseBody
	@RequestMapping("/getUnBidProjectCompListJson")
	public Pagination getUnBidProjectCompListJson() {
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("compCode", request.getParameter("scompCode"));
		page.getConditions().put("compName", request.getParameter("scompName"));
		page.getConditions().put("shortName", request.getParameter("sName"));
		page.getConditions().put("province", province);
		page = bidProjectManager.getUnBidProjectCompList(page);
		return page;
	}

	/**
	 * 
	 * @category 批量添加配送企业到项目
	 * @auth 陈镜宇
	 * @param projId
	 * @param drugs
	 * @return
	 * @date 2015年6月12日
	 */
	@ResponseBody
	@RequestMapping("/batchSubmitCompTOProj")
	public Pagination batchSubmitCompTOProj(String drugs) {
		Pagination page = new Pagination(request);
		try {
			if (drugs != null && !"".equals(drugs)) {
				Gson gson = new Gson();
				Type type = new TypeToken<List<BidProjCompany>>() {}.getType();
				List<BidProjCompany> list = gson.fromJson(drugs, type);
				SysUser loginUser = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
				for (BidProjCompany b : list) {
					b.setProjDelId(UUID.randomUUID().toString());
					b.setUpdDatetime(new Timestamp(System.currentTimeMillis()));
					b.setUpdUser(loginUser.getId());
					b.setStatus(1);
				}
				bidProjectManager.batchSubmitCompTOProj(list);
				page.setSuccess(true);
			}
		} catch (Exception e) {
			logger.error("批量添加配送企业失败：", e);
			page.setSuccess(false);
		}
		return page;
	}


	/**
	 * 
	 *@category 跳向已添加药品页面
	 *@author 徐国鹏
	 *@date 2015年8月19日 上午10:38:13
	 *@return 
	 */
	@RequestMapping("/toAddedBidProjectCompsList")
	public String toAddedBidProjectCompsList(){
		request.setAttribute("projId", request.getParameter("projId"));
		String name = request.getParameter("name");
		try {
			if (StringUtils.isNotBlank(name)){
				name = new String(name.getBytes("ISO8859-1"),"utf-8");
			}
			request.setAttribute("name", name);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.toString());
		}
		return "/pro/project/bidProjCompanyList";
	}
	
	
	@RequestMapping("/getAddedBidProjectCompsList")
	@ResponseBody
	public Pagination getAddedBidProjectCompsList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("compCode", request.getParameter("scompCode"));
		page.getConditions().put("compName", request.getParameter("scompName"));
		page.getConditions().put("shortName", request.getParameter("sName"));
		page = bidProjectManager.getAddedBidProjectCompsList(page);
		return page; 
	}
	
	/**
	 * @category 项目已添加配送企业启用停用
	 * @author 韩守松
	 * @date 2015年7月8日
	 * @param @return
	 */
	@RequestMapping("/changeCompStatus")
	@ResponseBody
	public boolean changeCompStatus(BidProjCompany bidProjCompany) {
		boolean flag = false;
		String projDelId = request.getParameter("projDelId");
		String status = request.getParameter("status");
		SysUser sysUser = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		try {
			bidProjCompany.setProjDelId(projDelId);
			if (StringUtils.isNotEmpty(status)) {
				bidProjCompany.setStatus(Integer.valueOf(status));
			}
			bidProjCompany.setUpdDatetime(new Date());
			bidProjCompany.setUpdUser(sysUser.getId());
			flag = bidProjectManager.updateCompStatus(bidProjCompany, bidProjCompany.getStatus());
			return flag;
		} catch (Exception e) {
            e.printStackTrace();
			logger.error("采购项目药品信息保存修改错误" + e);
			return flag;
		}
	}

	/**
	 * @category 项目已添加配送企业批量启用停用
	 * @author 韩守松
	 * @date 2015年7月8日
	 * @param @return
	 */
	@RequestMapping("/batchChangeCompStatus")
	@ResponseBody
	public boolean batchChangeCompStatus(BidProjCompany bidProjCompany) {
		boolean flag = false;
		try {
			Date date = new Date();
			String projDelIdList = request.getParameter("array");
			String projDelId = "";
			Integer status = null;
			SysUser sysUser = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			JSONArray jsonarray = JSON.parseArray(projDelIdList);
			for (int i = 0; i < jsonarray.size(); i++) {
				JSONObject json = (JSONObject) jsonarray.get(i);
				projDelId = json.getString("projDelId");
				status = json.getInteger("status");
				bidProjCompany.setProjDelId(projDelId);
				bidProjCompany.setCompId(json.getString("compId"));
				bidProjCompany.setProjId(json.getString("projId"));
				bidProjCompany.setStatus(status);
				bidProjCompany.setUpdDatetime(date);
				bidProjCompany.setUpdUser(sysUser.getId());
				flag = bidProjectManager.updateCompStatus(bidProjCompany, bidProjCompany.getStatus());
				if (!flag) break;
			}
			return flag;
		} catch (Exception e) {
			logger.error("已添加药品批量处理出错-->", e);
			return flag;
		}

	}
	
	/**
	 * 
	 * @category 跳转到已添加药品列表
	 * @auth 单大伟
	 * @param projId
	 * @return
	 * @throws UnsupportedEncodingException 
	 * @date 2015年6月13日
	 */
	@RequestMapping("/toAddedBidProjectDrugsList")
	public String toAddedBidProjectDrugsList() throws UnsupportedEncodingException {
		request.setAttribute("projId", request.getParameter("projId"));
		request.setAttribute("projName", URLDecoder.decode(request.getParameter("projName"), "utf-8"));
		return "/pro/project/bidAddedProjectDrugsList";
	}

	/**
	 * 
	 * @category 获取已添加药品列表Json
	 * @author yanke
	 * @date 2015年6月13日 Pagination
	 */
	@ResponseBody
	@RequestMapping("/getAddedBidProjectDrugListJson")
	public Pagination getAddedBidProjectDrugListJson() {
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("drugCode", request.getParameter("sdrugCode"));
		page.getConditions().put("drugName", request.getParameter("sdrugName"));
		page.getConditions().put("compName", request.getParameter("sdrugComp"));
		page.getConditions().put("drugAttr", request.getParameter("sbaseDrug"));
		page.getConditions().put("isLowprice", request.getParameter("slowDrug"));
		page.getConditions().put("status", request.getParameter("status"));
		page = bidProjectManager.getAddedBidProjectDrugList(page);
		return page;

	}

	/**
	 * @category 项目已添加药品启用停用
	 * @author 韩守松
	 * @date 2015年7月8日
	 * @param @return
	 */
	@RequestMapping("/changeStatus")
	@ResponseBody
	public boolean changeStatus(BidProjdrugs bidProjdrugs) {
		boolean flag = false;
		String projDrugId = request.getParameter("projDrugId");
		String status = request.getParameter("status");
		SysUser sysUser = (SysUser) request.getSession().getAttribute(
				Constants.USERINFO);
		try {
			bidProjdrugs.setProjDrugId(projDrugId);
			if (StringUtils.isNotEmpty(status)) {
				bidProjdrugs.setStatus(Short.valueOf(status));
			}
			bidProjdrugs.setUpdDatetime(Timestamp.valueOf(new SimpleDateFormat(
					"yyyy-MM-dd HH:mm:ss").format(new Date())));
			bidProjdrugs.setUpdUser(sysUser.getId());
			flag = bidProjectManager.updateStatus(bidProjdrugs,
					bidProjdrugs.getStatus());
			return flag;
		} catch (Exception e) {
			logger.error("采购项目药品信息保存修改错误-->" + e);
			return flag;
		}
	}

	/**
	 * @category 项目已添加药品批量启用停用
	 * @author 韩守松
	 * @date 2015年7月8日
	 * @param @return
	 */
	@RequestMapping("/batchChangeStatus")
	@ResponseBody
	public boolean batchChangeStatus(BidProjdrugs bidProjdrugs) {
		boolean flag = false;
		try {
			Date date = new Date();
			SimpleDateFormat format = new SimpleDateFormat(
					"yyyy-MM-dd HH:mm:ss");
			String projDrugIdList = request.getParameter("array");
			String projDrugId = "";
			Short status = null;
			SysUser sysUser = (SysUser) request.getSession().getAttribute(
					Constants.USERINFO);
			JSONArray jsonarray = JSON.parseArray(projDrugIdList);
			for (int i = 0; i < jsonarray.size(); i++) {
				JSONObject json = (JSONObject) jsonarray.get(i);
				projDrugId = json.getString("projDrugId");
				status = json.getShortValue("status");
				bidProjdrugs.setProjDrugId(projDrugId);
				bidProjdrugs.setStatus(status);
				bidProjdrugs.setUpdDatetime(Timestamp.valueOf(format
						.format(date)));
				bidProjdrugs.setUpdUser(sysUser.getId());
				flag = bidProjectManager.updateStatus(bidProjdrugs,
						bidProjdrugs.getStatus());
			}
			return flag;
		} catch (Exception e) {
			logger.error("已添加药品批量处理出错-->" + e);
			return flag;
		}

	}

	@RequestMapping("/toHospEditList")
	public String toHospEditList(String projId, String projName) throws UnsupportedEncodingException {
		request.setAttribute("projId", projId);
		request.setAttribute("proName", URLDecoder.decode(projName, "UTF-8"));
		DicAreaForm area = dicAreaManager.getDicAreaById(province);
		request.setAttribute("area", area);
		return "/pro/project/bidProjhospEdit";
	}

	@RequestMapping("/getAddedBidProjectHospsList")
	@ResponseBody
	public Pagination getAddedBidProjectHospsList(){
		Pagination page = new Pagination(request);
		String hospClassifys = request.getParameter("hospClassifys");
		String hospType = request.getParameter("hospType");
		String projId = request.getParameter("projId");
		String townId = request.getParameter("areaId");
		String cityId = request.getParameter("fahterId");
		String hospName = request.getParameter("hospName");
		String hospClassify = request.getParameter("hospClassify");
		String hospCode = request.getParameter("hospCode");
		String status = request.getParameter("status");
		String areaId=AreaUtil.getAreaStartCode(province, cityId, townId);
		if (areaId.equals(province.substring(0, areaId.length()))){
			areaId = null;
		}

		if (StringUtils.isNotEmpty(projId)) {
			page.getConditions().put("projId", projId.trim());
		}
		if (StringUtils.isNotEmpty(areaId)) {
			page.getConditions().put("areaId", areaId.trim());
		}

		if (StringUtils.isNotEmpty(hospName)) {
			page.getConditions().put("hospName", hospName.trim());
		}
		
		if (StringUtils.isNotEmpty(hospClassify)) {
			page.getConditions().put("hospClassify", hospClassify.trim());
		}
		if (StringUtils.isNotEmpty(hospCode)) {
			page.getConditions().put("hospCode", hospCode.trim());
		}
		if (StringUtils.isNotEmpty(status)) {
			page.getConditions().put("status", status.trim());
		}
		if (StringUtils.isNotEmpty(hospClassifys)) {
			page.getConditions().put("hospClassifys", hospClassifys.trim());
		}
		if (StringUtils.isNotEmpty(hospType)) {
			page.getConditions().put("hospType", hospType.trim());
		}
		return bidProjectManager.getAddedBidProjectHospList(page);
	}
	/**
	 * @category 跳转到已添加生产企业列表
	 * @author 徐国鹏
	 * @date   2015年7月9日
	 * @param  @return
	 */
	@RequestMapping("/toAddedBidProjectDelCompsList")
	public String toAddedBidProjectDelCompsList() {
		request.setAttribute("projId", request.getParameter("projId"));
		String name = request.getParameter("name");
		try {
			if (StringUtils.isNotBlank(name)){
				name = new String(name.getBytes("ISO8859-1"),"utf-8");
			}
			request.setAttribute("name", name);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.toString());
		}
		return "/pro/project/bidProjDelCompanyList";
	}
	
	/**
	 * @category 去项目切换页面
	 * @author 应晓川
	 * @date   2015年9月15日10:16:53
	 * @param  @return
	 */
	@RequestMapping("/toChangeBidProjectList")
	public String toChangeBidProject(){
		return "/pro/project/changeBidProject/list";
	}
	
	/**
	 * @category 获取项目切换数据
	 * @author 应晓川
	 * @date   2015年9月15日10:16:53
	 * @param  @return
	 */
	@ResponseBody
	@RequestMapping("/getChangeBidProjectList")
	public Pagination getChangeBidProjectList() {
		Pagination page = new Pagination(request);
		SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
		StdCompinfo sc =(StdCompinfo)user.getInfo();
		if(sc!=null){
			String compId = sc.getCompId();
			page.getConditions().put("id", compId);
		}else{
			page.getConditions().put("id", user.getId());
		}
		String defaultProjId =  user.getDefaultProjId();
		try {
			if (StringUtils.isNotBlank(defaultProjId)) {
				page.setForm(defaultProjId);
			}
			DbUtil.jsonToMap(request, page);
			page = bidProjectManager.getChangeBidProjectList(page);
		} catch (Exception e) {
			logger.error(" 获取项目切换数据是失败-->", e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 设置默认项目
	 * @author 应晓川
	 * @date   2015年9月15日10:16:53
	 * @param  @return
	 */
	@ResponseBody
	@RequestMapping("/toSetDefaultProj")
	public Pagination toSetDefaultProj(String projId) {
		Pagination page = new Pagination(request);
		SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
		try {
			if(StringUtils.isNotBlank(projId)){
				user.setDefaultProjId(projId);
				user.setUpdDateTime(new Date());
				if(bidProjcompprofileManager.update(user)){
					page.setSuccess(true);
				}
			}
		} catch (Exception e) {
			logger.error(" 设置默认项目失败-->", e);
			page.setSuccess(false);
		}
		return page;
	}
	
	/**
	 * @category 重置默认项目
	 * @author 应晓川
	 * @date   2015年9月15日14:12:20
	 * @param  @return
	 */
	@ResponseBody
	@RequestMapping("/toReSetDefaultProj")
	public Pagination toReSetDefaultProj(String projId) {
		Pagination page = new Pagination(request);
		SysUser user = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
		try {
			user.setDefaultProjId("");
			user.setUpdDateTime(new Date());
			if(bidProjcompprofileManager.update(user)){
				page.setSuccess(true);
			}
		} catch (Exception e) {
			logger.error(" 设置默认项目失败-->", e);
			page.setSuccess(false);
		}
		return page;
	}
	/**
	 * @category 获取不重复项目值
	 * @author 韩守松
	 * @date   2015年9月15日
	 * @param  @return
	 */
	@RequestMapping("/getDataProjList")
	@ResponseBody
	public Pagination getDataProjList() {
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("projCode", request.getParameter("projCode"));
		page.getConditions().put("name", request.getParameter("name"));
		page.getConditions().put("status", request.getParameter("status"));
		page.getConditions().put("zbStatus", request.getParameter("zbStatus"));
		page.getConditions().put("projCat", request.getParameter("projCat"));
		return bidProjectManager.getDataProjList(page);
	}
	
	/**
	 * @category 获取项目已添加的数量和即将添加的数量
	 * @author 应晓川
	 * @date   2015年9月29日10:50:18
	 * @param  @return
	 */
	@RequestMapping("/getDrugCount")
	@ResponseBody
	public Pagination getDrugCount() {
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("drugcatalogId", request.getParameter("drugcatalogId"));
		return bidProjectManager.getDrugCount(page);
	}
	
	/*********************************采购项目*****************************************/
	/**
	 * 
	 * @category 跳向采购项目列表
	 * @author 邱磊
	 * @date 2015年6月11日 上午10:54:04
	 * @return
	 */
	@RequestMapping("/toPurList")
	public String toPurList() {
		return "/pro/project/bidPurProjectList";
	}
	/**
	 * 
	 * @category 查询采购项目列表
	 * @author 邱磊
	 * @date 2015年6月11日 上午11:48:38
	 * @param projCode
	 * @param name
	 * @param status
	 * @return
	 */
	@RequestMapping("/getPurDataList")
	@ResponseBody
	public Pagination getPurDataList(String projCode, String name, String status) {
		Pagination page = new Pagination(request);
		if (null != projCode && !"".equals(projCode.trim())) {
			page.getConditions().put("projCode", projCode.trim());
		}
		if (null != name && !"".equals(name.trim())) {
			page.getConditions().put("name", name.trim());
		}
		if (null != status && !"".equals(status.trim())) {
			page.getConditions().put("status", status.trim());
		}
		return bidProjectManager.getPurDataList(page);
	}
	/**
	 * 
	 * @category 跳转到未添加医疗机构页面
	 * @author 邱磊
	 * @date 2015年6月24日 上午9:42:55
	 * @param projId
	 * @param proName
	 * @return
	 */
	@RequestMapping("/toPurHospList")
	public String toPurHospList(String projIdAddhosp, String proName) {
		projIdAddhosp = request.getParameter("projIdAddhosp");
		request.setAttribute("projId", projIdAddhosp);
		try {
			DicAreaForm area = dicAreaManager.getDicAreaById(province);
			request.setAttribute("area", area);
			request.setAttribute("proName", proName);
		} catch (Exception e) {
			logger.error("跳向添加医疗机构页面遇到异常", e);
		}
		return "/pro/project/purProjectAddHosp";
	}
	/**
	 * @category 进入添加配送企业页面
	 * @auth 单大伟
	 * @param model
	 * @param bidProject
	 * @return
	 * @date 2015年6月13日
	 */
	@RequestMapping("/toPurCompList")
	public String toPurCompList(Model model, BidProject bidProject) {
		bidProject.setProjId(request.getParameter("projIdAddcomp"));
		model.addAttribute("bidProject", bidProjectManager.getBidProjectById(bidProject.getProjId()));
		return "/pro/project/bidPurProjectCompsEdit";
	}
	/**
	 * 
	 * @category 跳向新增采购项目
	 * @author 张俊
	 * @date 2015年6月11日
	 * @return
	 */
	@RequestMapping("/toPurEdit")
	public String toPurEdit(Model model, String projId) {
		Pagination page = new Pagination();
		BidProject bidProject = new BidProject();
		try {
			if (StringUtils.isNotEmpty(projId)) {
				bidProject = bidProjectManager.getBidProjectById(projId);
				bidProject = bidProject == null ? new BidProject() : bidProject;
				request.setAttribute("flag", 2);//编辑
				page.getConditions().put("projRange", bidProject.getProjRange());
			}else{
				request.setAttribute("flag", 1);//新增
			}
			model.addAttribute("bidProject", bidProject);
			List<DicSys> list = DicSysUtil.getDicListByClassCode(Constants.PROJ_CAT);
			request.setAttribute("list", list);
			
			List<DicSys> list2 = DicSysUtil.getDicListByClassCode(Constants.HOSP_CAT);
			request.setAttribute("list2", list2);
			
			DicAreaForm dicArea = dicAreaManager.getDicAreaById(province);
			request.setAttribute("sysProvinceName", dicArea.getAreaName());
			request.setAttribute("sysProvince", province);
			request.setAttribute("compCount", stdCompinfoManager.queryStdCompCount(page).getRows());
			
			String areaId=AreaUtil.getAreaStartCode(province, null, null);
			page.getConditions().put("areaId", areaId);
			request.setAttribute("hospCount", hospInfoManager.getHospCount(page).getRows());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "/pro/project/bidPurProjectEdit";
	}
	/**
	 * @category 跳转未添加药品页面
	 * @auth 陈镜宇
	 * @param model
	 * @param bidProject
	 * @return
	 * @date 2015年6月11日
	 */
	@RequestMapping("/toPurUnBidProjectDrugsList")
	public String toPurUnBidProjectDrugsList(Model model, BidProject bidProject) {
		model.addAttribute("bidProject", bidProjectManager.getBidProjectById(bidProject.getProjId()));
		request.setAttribute("projId", bidProject.getProjId());
		return "/pro/project/bidPurProjectDrugsEdit";
	}
	/**
	 * 
	 * @category 启用、停用
	 * @author 邱磊
	 * @date 2015年6月24日 上午9:48:36
	 * @param projId
	 *            项目ID
	 * @param status
	 *            状态：1启用，0停用
	 * @return
	 */
	@RequestMapping("/switchPurStatus")
	@ResponseBody
	public String switchPurStatus(BidProject data) {
		SysUser user = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		data.setUpdUser(user.getId());
		try {
			bidProjectManager.switchPurStatus(data);
			return "success";
		} catch (Exception e) {
			logger.error("启停操作失败：", e);
			return "failed";
		}
	}
	/**
	 * @category 跳转到已添加医疗机构页面
	 * @author 韩守松
	 * @date   2015年7月9日
	 * @param  @param model
	 * @param  @param bidProject
	 * @param  @return
	 */
	@RequestMapping("/toAddedBidProjectHospsList")
	public String toAddedBidProjectHospsList(Model model, BidProject bidProject){
		request.setAttribute("projId", request.getParameter("projId"));
		request.setAttribute("proName", request.getParameter("projName"));
		try {
			DicAreaForm area = dicAreaManager.getDicAreaById(province);
			request.setAttribute("area", area);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.toString());
		}
		return "/pro/project/bidPurProjhospEdit";
	}
	/**
	 * 
	 * @category 获取未添加医疗机构列表数据
	 * @author 邱磊
	 * @date 2015年6月24日 上午9:43:20
	 * @return
	 */
	@RequestMapping("/getHospDataList")
	@ResponseBody
	public Pagination getHospDataList() {
		Pagination page = new Pagination(request);
		String projId = request.getParameter("projId");
		String area1 = province;
		String area2 = request.getParameter("area2");
		String area3 = request.getParameter("area3");
		String hospName = request.getParameter("hospName");
		String hospClassify = request.getParameter("hospClassify");
		String hospCode = request.getParameter("hospCode");
		String areaId=AreaUtil.getAreaStartCode(area1, area2, area3);
		if (StringUtils.isNotEmpty(areaId)) {
		    page.getConditions().put("areaId", areaId.trim());
		}
		if (StringUtils.isNotEmpty(projId)) {
			page.getConditions().put("projId", projId.trim());
		}
		if (StringUtils.isNotEmpty(hospName)) {
			page.getConditions().put("hospName", hospName.trim());
		}
		if (StringUtils.isNotEmpty(hospClassify)) {
			page.getConditions().put("hospClassify", hospClassify.trim());
		}
		if (StringUtils.isNotEmpty(hospCode)) {
			page.getConditions().put("hospCode", hospCode.trim());
		}
		return bidProjectManager.getHospList(page);
	}
	
	/**
	 * 
	 * @category 添加医疗机构
	 * @author 邱磊
	 * @date 2015年6月24日 上午9:46:55
	 * @param porjId
	 * @param hospId
	 * @return
	 */
	@RequestMapping("/addPurHost")
	@ResponseBody
	public String addPurHost(String porjId, String hospCode) {
		SysUser sysUser = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		
		return bidProjectManager.addHost(porjId, hospCode, sysUser.getId());
	}
	/**
	 * 
	 * @category 批量添加医疗机构
	 * @author 邱磊
	 * @date 2015年6月24日 上午9:47:10
	 * @param array
	 * @return
	 */
	@RequestMapping("/batchAddPurHosp")
	@ResponseBody
	public Pagination batchAddPurHosp(String array) {
		Pagination page = new Pagination(request);
		SysUser sysUser = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		try {
			if (array != null && !"".equals(array)) {
				Gson gson = new Gson();
				Type type = new TypeToken<List<BidProjhospital>>() {}.getType();
				List<BidProjhospital> list = gson.fromJson(array, type);
				if (list != null && !list.isEmpty()) {
					for (BidProjhospital dp : list) {
						dp.setUpdUser(sysUser.getId());
					}
					bidProjectManager.batchAddPurHosp(list);
					page.setSuccess(true);
				}
			}
		} catch (Exception e) {
			logger.error("批量添加医疗机构失败：", e);
			page.setSuccess(false);
		}
		return page;
	}
	/**
	 * @category 跳转到已添加配送企业列表
	 * @author 韩守松
	 * @date   2015年7月9日
	 * @param  @return
	 */
	@RequestMapping("/toAddedBidPurProjectCompsList")
	public String toAddedBidPurProjectCompsList() {
		request.setAttribute("projId", request.getParameter("projId"));
		request.setAttribute("projName", request.getParameter("projName"));
		return "/pro/project/bidPurProjCompanyList";
	}
	@RequestMapping("/dataPurEdit")
	@ResponseBody
	// jsp 中用js ajaxSubmit 进行触发保存，返回类型是json，所以需要加@ResponseBody
	// spring注解@ResponseBody处理ajax请求，json数据类型
	public Pagination dataPurEdit(BidProject bidProject) {
		Pagination page = new Pagination();
		SysUser sysUser = new SysUser();
		Result result = new Result();
		try {
			sysUser = (SysUser)request.getSession().getAttribute(Constants.USERINFO);
			if (StringUtils.isNotBlank(bidProject.getProjId())) {
					bidProject.setProjRange(bidProjectManager.getProjRangeById(bidProject.getProjId()));
					bidProject.setUpdUser(sysUser.getId());
					bidProject.setUpdDatetime(new Date());
					bidProjectManager.saveOrUpdateBidProject(bidProject);
			}else{
				if(StringUtils.isNotBlank(bidProject.getName()) && StringUtils.isNotBlank(bidProject.getProjCat()) ){
					bidProject.setProjId(UUID.randomUUID().toString());
					bidProject.setProjCode(AccountUtil.getProjSequence(provname));
					bidProject.setStatus(Whether.yes.getKey());
					bidProject.setCreateUser(sysUser.getId());
					bidProject.setCreateDatetime(new Date());
					bidProjectManager.loadToProjInfo(bidProject);
				}else{
					page.setSuccess(false);
					page.setMsg("项目名称、项目类型缺失！");
					return page;
				}
			}
			page.setSuccess(true);
		} catch (Exception e) {
			e.printStackTrace();
			page.setResult(result);
			page.setMsg("保存失败！");
		}
		return page;
	}
	/**
	 * @category 查询不同类型的医疗机构数目
	 * @auth 应晓川
	 * @param model
	 * @param bidProject
	 * @return
	 * @date 2015年6月13日
	 */
	@RequestMapping("/queryPurHospCount")
	@ResponseBody
	public Pagination queryPurHospCount(String projRange) {
		Pagination page = new Pagination();
		try {
			if (StringUtils.isNotBlank(projRange)) {
				 page.getConditions().put("projRange", projRange);
			}
			 String areaId=AreaUtil.getAreaStartCode(province, null, null);
			 page.getConditions().put("areaId", areaId);
			 hospInfoManager.getHospCount(page);
			 page.setSuccess(true);
		} catch (Exception e) {
			e.printStackTrace();
			page.setMsg("查询失败！");
		}
		return page;
	}
	/**
	 * 
	 *@category 跳向导入药品文件列表页面
	 *@author 邱磊
	 *@date 2015年11月11日 下午6:33:28
	 *@param 
	 *@return String
	 */
	@RequestMapping("/toImportFileList" )
	public String toImportFileList(){
		request.setAttribute("fileStatus", ConstantsUtil.importFileStatus);
		String projId = request.getParameter(Constants.PROJID);
		request.setAttribute(Constants.PROJID, projId);
		Map<String, Object> map = bidProjectManager.getProjInfoById(projId);
		request.setAttribute("projName", map.get("name").toString());
		return "/pro/project/bidProjDrugImportList";
	}
	
	/**
	 * 
	 * @category 跳转到已添加药品列表
	 * @auth 单大伟
	 * @param projId
	 * @return
	 * @throws UnsupportedEncodingException 
	 * @date 2015年6月13日
	 */
	@RequestMapping("/toAddedBidPurProjectDrugsList")
	public String toAddedBidPurProjectDrugsList() throws UnsupportedEncodingException {
		request.setAttribute("projId", request.getParameter("projId"));
		request.setAttribute("projName", URLDecoder.decode(request.getParameter("projName"), "utf-8"));
		return "/pro/project/bidAddedPurProjectDrugsList";
	}
	/**
	 * 
	 *@category 模板下载
	 *@author 邱磊
	 *@date 2015年11月12日 上午11:20:38
	 *@param 
	 *@return ResponseEntity<byte[]>
	 */
	@RequestMapping("/downloadModel")    
    public void downloadModel() throws Exception {  
		FileLoadForm form = new FileLoadForm();
		form.setRequest(request);
		form.setResponse(response);
		form.setFilePath(importDrugMobanPath);
		form.setFileName(importDrugMoban);
		FileUtil.downLoad(form);
	}
	/**
	 * 
	 *@category Excel导入药品
	 *@author 邱磊
	 *@date 2015年6月17日 下午8:54:52
	 *@param goodFile
	 *@return
	 */
	@RequestMapping("/bathImportView")
	@ResponseBody
	public Pagination bathImportView(@RequestParam(value="drugFile",required=false) MultipartFile drugFile ){
		Pagination page = new Pagination();
		try {
			SysUser user=(SysUser) request.getSession().getAttribute(Constants.USERINFO);
			page.setForm(user);
			page.getConditions().put(Constants.PROJID, request.getParameter(Constants.PROJID));
			FileUploadResult result = bidProjectManager.uploadFile(drugFile, page);
			String fileId = result.getFileId();
			if (StringUtils.isBlank(fileId)){
				page.setSuccess(false);
				page.setMsg(result.getResult());
				return page;
			}
			CheckDrugThread th = new CheckDrugThread(fileId, bidProjectManager);
			th.start();
            page.setSuccess(true);
            page.setMsg(result.getResult());
			return page;
		} catch (Exception e) {
			logger.error("文件上传失败！", e);
			page.setSuccess(false);
			page.setMsg("文件上传失败！");
			return page;
		} 
	}
	/**
	 * 
	 * @category 获取非项目药品数据
	 * @auth 陈镜宇
	 * @param projId
	 * @return
	 * @date 2015年6月11日
	 */
	@ResponseBody
	@RequestMapping("/getUnBidPurProjectDrugListJson")
	public Pagination getUnBidPurProjectDrugListJson(String projId,
			String sdrugCode, String sdrugName, String sdrugComp,
			String sbaseDrug, String slowDrug) {
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", projId);
		page.getConditions().put("drugCode", sdrugCode);
		page.getConditions().put("drugName", sdrugName);
		page.getConditions().put("drugComp", sdrugComp);
		page.getConditions().put("baseDrug", sbaseDrug);
		page.getConditions().put("lowDrug", slowDrug);
		return bidProjectManager.getUnBidProjectDrugList(page);
	}
	/**
	 * @category 项目已添加配送企业启用停用
	 * @author 韩守松
	 * @date 2015年7月8日
	 * @param @return
	 */
	@RequestMapping("/changePurCompStatus")
	@ResponseBody
	public boolean changePurCompStatus(BidProjCompany bidProjCompany) {
		boolean flag = false;
		String projDelId = request.getParameter("projDelId");
		String status = request.getParameter("status");
		SysUser sysUser = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
		try {
			bidProjCompany.setProjDelId(projDelId);
			if (StringUtils.isNotEmpty(status)) {
				bidProjCompany.setStatus(Integer.valueOf(status));
			}
			bidProjCompany.setUpdDatetime(new Date());
			bidProjCompany.setUpdUser(sysUser.getId());
			flag = bidProjectManager.updateCompStatus(bidProjCompany, bidProjCompany.getStatus());
			return flag;
		} catch (Exception e) {
            e.printStackTrace();
			logger.error("采购项目药品信息保存修改错误" + e);
			return flag;
		}
	}
	/**
	 * @category 项目已添加配送企业批量启用停用
	 * @author 韩守松
	 * @date 2015年7月8日
	 * @param @return
	 */
	@RequestMapping("/batchChangePurCompStatus")
	@ResponseBody
	public boolean batchChangePurCompStatus(BidProjCompany bidProjCompany) {
		boolean flag = false;
		try {
			Date date = new Date();
			String projDelIdList = request.getParameter("array");
			String projDelId = "";
			Integer status = null;
			SysUser sysUser = (SysUser) request.getSession().getAttribute(Constants.USERINFO);
			JSONArray jsonarray = JSON.parseArray(projDelIdList);
			for (int i = 0; i < jsonarray.size(); i++) {
				JSONObject json = (JSONObject) jsonarray.get(i);
				projDelId = json.getString("projDelId");
				status = json.getInteger("status");
				bidProjCompany.setProjDelId(projDelId);
				bidProjCompany.setCompId(json.getString("compId"));
				bidProjCompany.setProjId(json.getString("projId"));
				bidProjCompany.setStatus(status);
				bidProjCompany.setUpdDatetime(date);
				bidProjCompany.setUpdUser(sysUser.getId());
				flag = bidProjectManager.updateCompStatus(bidProjCompany, bidProjCompany.getStatus());
				if (!flag) break;
			}
			return flag;
		} catch (Exception e) {
			logger.error("已添加药品批量处理出错-->", e);
			return flag;
		}
	}
	@RequestMapping("/getAddedBidPurProjectCompsList")
	@ResponseBody
	public Pagination getAddedBidPurProjectCompsList(){
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("compCode", request.getParameter("scompCode"));
		page.getConditions().put("compName", request.getParameter("scompName"));
		page.getConditions().put("shortName", request.getParameter("sName"));
		page = bidProjectManager.getAddedBidProjectCompsList(page);
		return page; 
	}
	
	/**
	 * 
	 * @category 获取已添加药品列表Json
	 * @author yanke
	 * @date 2015年6月13日 Pagination
	 */
	@ResponseBody
	@RequestMapping("/getAddedBidPurProjectDrugListJson")
	public Pagination getAddedBidPurProjectDrugListJson() {
		Pagination page = new Pagination(request);
		page.getConditions().put("projId", request.getParameter("projId"));
		page.getConditions().put("drugCode", request.getParameter("sdrugCode"));
		page.getConditions().put("drugName", request.getParameter("sdrugName"));
		page.getConditions().put("compName", request.getParameter("sdrugComp"));
		page.getConditions().put("drugAttr", request.getParameter("sbaseDrug"));
		page.getConditions().put("isLowprice", request.getParameter("slowDrug"));
		page.getConditions().put("status", request.getParameter("status"));
		page = bidProjectManager.getAddedBidProjectDrugList(page);
		return page;
	}
	/**
	 * @category 项目已添加药品启用停用
	 * @author 韩守松
	 * @date 2015年7月8日
	 * @param @return
	 */
	@RequestMapping("/changePurStatus")
	@ResponseBody
	public boolean changePurStatus(BidProjdrugs bidProjdrugs) {
		boolean flag = false;
		String projDrugId = request.getParameter("projDrugId");
		String status = request.getParameter("status");
		SysUser sysUser = (SysUser) request.getSession().getAttribute(
				Constants.USERINFO);
		try {
			bidProjdrugs.setProjDrugId(projDrugId);
			if (StringUtils.isNotEmpty(status)) {
				bidProjdrugs.setStatus(Short.valueOf(status));
			}
			bidProjdrugs.setUpdDatetime(Timestamp.valueOf(new SimpleDateFormat(
					"yyyy-MM-dd HH:mm:ss").format(new Date())));
			bidProjdrugs.setUpdUser(sysUser.getId());
			flag = bidProjectManager.updateStatus(bidProjdrugs,
					bidProjdrugs.getStatus());
			return flag;
		} catch (Exception e) {
			logger.error("采购项目药品信息保存修改错误-->" + e);
			return flag;
		}
	}
		
	
	/**
	 * 
	 *@category 获取药品导入文件列表
	 *@author 邱磊
	 *@date 2015年11月11日 下午6:34:06
	 *@param 
	 *@return Pagination
	 */
	@RequestMapping("/getImportFileDataList")
	@ResponseBody
	public Pagination getImportFileDataList(){
		Pagination page = new Pagination(request);
		page.getConditions().put(Constants.PROJID, request.getParameter(Constants.PROJID));
		page.getConditions().put("fileName", request.getParameter("fileName"));
		page.getConditions().put("starttime", request.getParameter("starttime"));
		page.getConditions().put("endtime", request.getParameter("endtime"));
		page.getConditions().put("status", request.getParameter("status"));
		page.getConditions().put("filetype", String.valueOf(Constants.WENJIAN_SHANGCHUAN_YAOPING_DAORU));
		page = bidProjectManager.getImportFileDataList(page);
		return page;
	}
	
	
	@RequestMapping("/toImoprtDrugView")
	public String toImoprtDrugView(){
		request.setAttribute(Constants.FILEID, request.getParameter(Constants.FILEID));
		request.setAttribute(Constants.PROJID, request.getParameter(Constants.PROJID));
		return "/pro/project/bidProjdrugImportView";
	}
	/**
	 * 
	 *@category 获取预览列表
	 *@author 邱磊
	 *@date 2015年11月12日 上午8:32:59
	 *@param
	 */
	@RequestMapping("/getImportDrugView")
	@ResponseBody
	public Pagination getImportDrugView(){
		Pagination page = new Pagination();
		page.getConditions().put(Constants.FILEID, request.getParameter(Constants.FILEID));
		page.getConditions().put(Constants.DRUGNAME, request.getParameter(Constants.DRUGNAME));
		page.getConditions().put(Constants.COMPNAME, request.getParameter(Constants.COMPNAME));
		page = bidProjectManager.getImportDrugView(page);
		return page;
	}
	/**
	 * 
	 *@category 预览时导入验证成功的商品
	 *@author 邱磊
	 *@date 2015年11月12日 上午10:38:47
	 *@param 
	 *@return Pagination
	 */
	@RequestMapping("/importDrug")
	@ResponseBody
	public Pagination importDrug(){
		Pagination page = new Pagination();
		String fileId = request.getParameter("fileId");
		try {
			sfmanager.updateImportFileStatus(Constants.WENJIAN_STATUS_DAORUZHONG, fileId);
			int flag = bidProjectManager.importDrug(request.getParameter(Constants.FILEID));
			page.setSuccess(true);
			page.setMsg("成功导入药品" + flag + "条");
			sfmanager.updateImportFileStatus(Constants.WENJIAN_STATUS_DAORUCHENGGONG, fileId);
		} catch (Exception e) {
			logger.error("药品导入：", e);
			sfmanager.updateImportFileStatus(Constants.WENJIAN_STATUS_DAORUSHIBAI, fileId);
			page.setSuccess(false);
			page.setMsg("导入失败！");
		}
		return page;
	}
	/**
	 * 
	 *@category 预览时放弃导入
	 *@author 邱磊
	 *@date 2015年11月12日 上午10:58:54
	 *@param 
	 *@return Pagination
	 */
	@RequestMapping("/deleteImportDrug")
	@ResponseBody
	public Pagination deleteImportDrug(){
		Pagination page = new Pagination();
		try {
			bidProjectManager.deleteImportDrug(request.getParameter("fileId"));
			page.setSuccess(true);
		} catch (Exception e) {
			logger.error("药品放弃导入：", e);
			page.setSuccess(false);
			page.setMsg("放弃失败！");
		}
		return page;
	}
	/**
	 * 
	 *@category 下载结果
	 *@author 邱磊
	 *@date 2015年11月12日 上午11:20:38
	 *@param 
	 *@return ResponseEntity<byte[]>
	 */
	@RequestMapping("/downloadResult")    
    public void downloadResult() throws Exception {  
		SysImportFileInfo map = sfmanager.getImportFileById(request.getParameter("fileId"));
		FileLoadForm form = new FileLoadForm();
		form.setRequest(request);
		form.setResponse(response);
		form.setFilePath(uploadPath + importDrugResultPath);
		form.setFileName(map.getFileName());
		FileUtil.downLoad(form);
	}
	/**
	 * 
	 *@category 预览导入时校验是否有重复导入
	 *@author 邱磊
	 *@date 2015年11月17日 下午2:20:06
	 *@param 
	 *@return Pagination
	 */
	@RequestMapping("/checkReImport")    
	@ResponseBody
	public Pagination checkReImport(){
		Pagination page = new Pagination();
		page.getConditions().put(Constants.FILEID, request.getParameter("fileId"));
		page = bidProjectManager.checkReImport(page);
		if (StringUtils.isBlank(page.getMsg())){
			page.setMsg("");
		}
		return page;
	}
}





class CheckDrugThread extends Thread{
	private String fileId;
	private BidProjectManager manager;
	public CheckDrugThread(String fileId, BidProjectManager manager){
		this.fileId = fileId;
		this.manager = manager;
	}
	public void run (){
		try {
			manager.bathImport(fileId);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}